Cannot modify a button from the menu

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


Sponsored Links
 Hi,

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.

Thanks!
-Jimmy



The code:

package com.innodesign.testingbuttons;

import android.app.Activity;
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.net.Uri;
import android.content.Intent;

@SuppressWarnings("unused")
public class TestingButtons extends Activity {
        protected void onCreate(Bundle icicle) {
                super.onCreate(icicle);
                setContentView(R.layout.main);

                final ImageButton myButton12 = (ImageButton) findViewById
(R.id.btid12);
                myButton12.setOnClickListener(new View.OnClickListener()
{
                public void onClick(View v) {
                // Perform action on click
                        phoneNumber.setText(phoneNumber.getText()+"#");
                        }
                });
        }

    @Override
    public boolean onCreateOptionsMenu(Menu menu){
        super.onCreateOptionsMenu(menu);

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

        @Override
        public boolean onOptionsItemSelected(MenuItem item){
                switch(item.getItemId()){
                case 1:
                        shiftLeft();
                return true;
                case 2:
                return true;
                }
        return true;
        }

        public void shiftLeft(){
                myButton12.setLayoutParams(new AbsoluteLayout.LayoutParams(10, 
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
   DatagramSocketImpl.java. 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
   DatagramSocket.java which has never been used.

Can someone throw some light on this?

Thanks in advance
sumanth

--~--~---------~--~----~------------~-------~--~----~

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?