Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Java
public class Activ2 extends Activity implements OnClickListener {
	
	ImageButton butt1,butt2,butt3;
	TextView textview1;
	int buttonHeight =1, buttonWidth =1;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_activ2);
        butt1 = (ImageButton) findViewById(R.id.Butt1);
        textview1 = (TextView)findViewById(R.id.textView1);
        butt1.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				
"What to put on this part so the button can get the properties of the second button?"
 
			}
        });
Posted
Updated 10-Dec-13 3:02am
v2
Comments
Ganesh KP 10-Dec-13 1:39am    
What are you trying to achieve here? really I did not understand what you are going to do sorry man.:'(.

Please try to explain atleast what you want to do in simple terms.
TorstenH. 10-Dec-13 9:04am    
Let's start with giving them names and not just butts.

Then there are some questions:
- Where is butt2 located?
- is butt2 initalized?

1 solution

That's a closure so butt2 and butt3 are in scope, if you assign them before setting butt1's event handler you can just refer to them by name, i.e.

Java
butt1 = (ImageButton) findViewById(R.id.Butt1);
butt2 = (ImageButton) findViewById(R.id.Butt2);
butt1.setOnClickListener(new View.OnClickListener() {
  public void onClick(View v) {
    butt2.Text = "whatever";
  }
});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900