Cannot modify a button from the menu

by midicool » Thu, 05 Mar 2009 11:47:24 GMT

Sponsored Links

I am writing a program that has a menu. Once you press the menu button
and then select "Left",  it's supposed to change the attributes of
myButton12, an ImageButton.

However, I am getting a "myButton12 cannot be resolved" error message.
Please help me figure out what is wrong with this code.


The code:

package com.innodesign.testingbuttons;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AbsoluteLayout;
import android.widget.ImageButton;
import android.widget.Button;
import android.widget.EditText;
import android.content.Intent;

public class TestingButtons extends Activity {
        protected void onCreate(Bundle icicle) {

                final ImageButton myButton12 = (ImageButton) findViewById
                myButton12.setOnClickListener(new View.OnClickListener()
                public void onClick(View v) {
                // Perform action on click

    public boolean onCreateOptionsMenu(Menu menu){

                menu.add(0, 1, 0, "Left");
                menu.add(0, 2, 0, "Right");
    return true;

        public boolean onOptionsItemSelected(MenuItem item){
                case 1:
                return true;
                case 2:
                return true;
        return true;

        public void shiftLeft(){
                myButton12.setLayoutParams(new AbsoluteLayout.LayoutParams(10, 
10, 10));



Other Threads

1. IOException from RandomAccessFile ?


I have a RandomAccessFile in the main activity opened "r" (read only)
and can read from it no problems.

A menu choice from the main Activity launches another Activity (from
an intent set on the MenuItem).  The newly launched Activity
instantiates a RandomFileAccess also with "r" (readonly) on the same
file. The instantiation does NOT throw an exception.

But, in the second activity, when calling .seek() or and read methods
an IOException is thrown.

The same thing happens whether the file remains open or is closed from
the main Activity.

The file is /sdcard/MyFile.

The exception thrown reads:

WARN/System.err(880):     at

Does anyone know what this means or where I could look it up?

Thank you!


2. Battery Status and Signal Strength Acheivement

You can use:<>to
listen to the signal strength changes, just like the Android notification
bar does.


3. How to listen for any change in the contact database

4. contact listener


6. libaudio build issue

7. Memory Leak in layout with an image file statically linked as background