Hi its quite simple to make switch between buttons using switch case:-
package com.example.browsebutton;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener {
Button b1,b2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1=(Button)findViewById(R.id.button1);
b2=(Button)findViewById(R.id.button2);
b1.setOnClickListener(this);
b2.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
int id=v.getId();
switch(id) {
case R.id.button1:
Toast.makeText(getBaseContext(), "btn1", Toast.LENGTH_LONG).show();
//Your Operation
break;
case R.id.button2:
Toast.makeText(getBaseContext(), "btn2", Toast.LENGTH_LONG).show();
//Your Operation
break;
}
}}