Change Activity via Options Menu


Last Updated:

  1. gorjan

    gorjan New Member This Topic's Starter

    Joined:
    Oct 27, 2010
    Messages:
    3
    Likes Received:
    0
    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 R.id.item01:
    7.             Intent intentItem1 = new Intent(this, Item1Activity.class);
    8.             startActivityForResult(intentItem1, 0);
    9.             //startActivity(intentItem1);
    10.             return true;
    11.            
    12.         default: return super.onOptionsItemSelected(item);
    13.         }
    14.        
    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.
     

    Advertisement
  2. Martimus

    Martimus One bite at a time... Moderator

    Joined:
    Jul 9, 2010
    Messages:
    19,535
    Likes Received:
    4,045
    gorjan likes this.
  3. Steven58

    Steven58 Reformed PH VIP Member

    Joined:
    Feb 19, 2010
    Messages:
    32,920
    Likes Received:
    25,271
    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

Loading...