I´ve got a click listener to an email intent in my app, but I want to add a second button to do another thing? Sorry for the dum question, Im a begginer.
For the peoplew
First define your button variables in your activity/fragment
Button button1;
Button button2;
In the onCreate
(activity) or onCreateView
(fragment) method, link the button objects to the buttons in your layout, and set their onClickListener
s:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button1= (Button) findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
//do something
}
});
button2 = (Button) findViewById(R.id.button2);
button2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
//do something else
}
});
}
Your layout file should then have something like this: