1. Are you ready for the Galaxy S20? Here is everything we know so far!

Change Activity via Options Menu

Discussion in 'Introductions' started by gorjan, Oct 27, 2010.

  1. gorjan

    gorjan Lurker
    Thread Starter

    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.
     



    1. Download the Forums for Android™ app!


      Download

       
  2. Martimus

    Martimus One bite at a time...

    gorjan likes this.
  3. Steven58

    Moderator

    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
     
Loading...
Similar Threads - Change Activity via
  1. RedHeadDev
    Replies:
    4
    Views:
    343
  2. Sunny Rio
    Replies:
    9
    Views:
    411
  3. Madd63
    Replies:
    14
    Views:
    465
  4. Adam Brave
    Replies:
    3
    Views:
    758
  5. lynxstch
    Replies:
    2
    Views:
    753
  6. alexhob123
    Replies:
    12
    Views:
    539
  7. olbriar
    Replies:
    22
    Views:
    892
  8. EvasiveEmanual
    Replies:
    4
    Views:
    1,459
  9. Kuldip Somwanshi
    Replies:
    0
    Views:
    2,046
  10. Daniel Warren
    Replies:
    2
    Views:
    1,858

Share This Page

Loading...