Understanding Control of the Back Button in the Upper Left of Actionbar

Asked 2 years ago, Updated 2 years ago, 43 views

When I press the ActionBar Back button (<) in the upper left corner of ActionBarActivity, I would like to instruct you to return to the previous screen. How should I rewrite it?
Thank you for your cooperation.

@Override 
public boolean onOptionsItemSelected(MenuItem){ 
    switch(item.getItemId()){ 
        case R.id.home: 
            finish(); 
    } 
    return super.onOptionsItemSelected(item); 
}

android

2022-09-30 17:38

1 Answers

If you change R.id.home to android.R.id.home, it will work.


2022-09-30 17:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.