Proper way to handle action bar up button?

后端 未结 6 1928
没有蜡笔的小新
没有蜡笔的小新 2020-12-02 20:50

I use ActionBarSherlock (although I don\'t think it matters).

I have a Main activity and an About activity. I want the About activity to show the back-arrow by its l

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-02 21:17

    For who want to just go back in the previous activity, this is the simplest solution:

    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish(); //this method close current activity and return to previous
                return true;
        }
        return super.onOptionsItemSelected(item);
    }
    

提交回复
热议问题