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. How can multiple applications running at the same time

In the project in a different folder create a lot of java files

 I do not know how to make these applications in the run-time is at
the same time?

 How to write code?

 Thank you

 I'm using Eclipse 3.3 jdk 1.6

2. Muticast Socket

Hi All,

I am trying to test the multicast socket in Android. Has anyone been able to
open a multicast socket in andoid application.

During this investigation i found out couple of things

   1. There is a MulticastSocket.Java which extends DatagramSocket.Java. Can
   this be used?
   2. There is a PlainDatagramSocketImp.Java which extends This is in turn used when we CreateSocket for
   DatagramSocket. But we cannot import    PlainDatagramSocketImpl in android
   app. Also there is a function to set the DatagramSocketImpl in which has never been used.

Can someone throw some light on this?

Thanks in advance


3. Problem in Viewing table - sdk1.0

4. tslib is having some issues

5. Email attachment not being sent

6. ListView/ListActivity limit items until last item reached, like in Android Market

7. Does anybody know how to hang up a call?