Change Activity via Options Menu

Last Updated:

  1. gorjan

    gorjan New Member

    Hi All,

    I'm really new to Android development, so I have one basic question.
    I have the following code. I want to change the screen(the Activity) via Options menu:

    Code (Text):
    1. @Override
    2.     public boolean onOptionsItemSelected(MenuItem item) {
    3.         // TODO Auto-generated method stub
    4.         switch (item.getItemId())
    5.         {
    6.         case
    7.             Intent intentItem1 = new Intent(this, Item1Activity.class);
    8.             startActivityForResult(intentItem1, 0);
    9.             //startActivity(intentItem1);
    10.             return true;
    12.         default: return super.onOptionsItemSelected(item);
    13.         }
    15.     }
    But the activity doesn't change and the error message I receive while debugging is that "The resource doesn't exist"

    Any ideas?

    Thanks in advance.

  2. Martimus

    Martimus One bite at a time... Moderator

    gorjan likes this.
  3. Steven58

    Steven58 Reformed PH VIP Member

    Welcome to the Android Forums community! Glad you signed up! Please feel free to join the conversations! If you need any help getting around, please PM me and I'll try to help! :D

Share This Page