Reputation: 6556
I want to create another back button in my application. To do that I could use the finish method but the Action that I need already exists in Android KeyEvent.KEYCODE_BACK, than I was trying just to fire this event on my clicklistener, there's a way to do that?
Button btnVoltar = (Button) findViewById(R.id.btnVoltar);
btnVoltar.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// HERE I WANT TO USE KeyEvent.KEYCODE_BACK
}
});
Upvotes: 0
Views: 629
Reputation: 10083
Try this override onbackpressed and invoke it on your click
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed();
}
btnVoltar.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
Upvotes: 1