Clicking app icon doesn't trigger onOptionsItemSelected()

前端 未结 3 1557
别那么骄傲
别那么骄傲 2021-02-04 00:10

I\'m currently working on an Android app. I would like to use the app icon in the action bar to navigate to the \"home\" activity. I read on this page that all that needs to be

3条回答
  •  天涯浪人
    2021-02-04 00:36

    i dont know if we have the same problem.

    but, i was on that problem and now solved..

    do you add

    case android.R.id.home:
        Intent intent = new Intent(this, HomeActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;
    

    in HomeActivity ? this is false..

    you should put that code on your secondActivity.. because your home button on secondActivity, not HomeActivity

    case android.R.id.home:
         NavUtils.navigateUpFromSameTask(this);
         true;
    

    hope this helps you

提交回复
热议问题