Button selection in Android
- by dreamhigh
I have to create button options where each button performs specific task. So how to do the button selection. The code I tried is here.
Button b1
b1.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
if(v.getId()==R.id.button1)
{ //do something
}
if(v.getId()==R.id.button2)
{ //do something
}
});
For single button function its working fine with this code.
Button b1= (Button)findViewById(R.id.button1);
b1.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
if(v.getId()==R.id.button1)
{ //do something
}
}});