-4

i am new at android.I am using three dots menu in my android app but when i click on item on on three dots menu..my app crashes.can someone help me here is my code:

enter code here@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.my_menu,menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id=item.getItemId();
    switch (id){
        case R.id.account:
            Intent acc=new Intent(this,Account.class);
            startActivity(acc);
            break;
        case R.id.setting:
            Intent seting=new Intent(this,setting.class);
            startActivity(seting);
            break;
        case R.id.feedback:
            Intent feedback=new Intent(this,feedback.class);
            startActivity(feedback);
            break;
        case R.id.help:
            Intent help=new Intent(this,help.class);
            startActivity(help);
            break;
        case R.id.faq:
            Intent FAQ=new Intent(this,FAQ.class);
            startActivity(FAQ);
            break;
    }
    return true;
}

2 Answers2

1
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.my_menu,menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
       switch (item.getItemId()){
        case R.id.account:
            Intent acc=new Intent(this,Account.class);
            startActivity(acc);
            return true;

        case R.id.setting:
            Intent seting=new Intent(this,setting.class);
            startActivity(seting);
            break;
        case R.id.feedback:
            Intent feedback=new Intent(this,feedback.class);
            startActivity(feedback);
           return true;

        case R.id.help:
            Intent help=new Intent(this,help.class);
            startActivity(help);
          return true;

        case R.id.faq:
            Intent FAQ=new Intent(this,FAQ.class);
            startActivity(FAQ);
            return true;

            default:  
            return super.onOptionsItemSelected(item);  
    }
    return true;
}
Ankita
  • 1,129
  • 1
  • 8
  • 15
0

Seems there is nothing wrong with the code.

This could be issue with declration in manifest.

Make sure the activities account, help are declared in manifest.

Harminder Singh
  • 316
  • 1
  • 11