lundi 18 mai 2015

ActivityNotFoundException When calling another xml with action menu bar, it cause app stop

This is the code in MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
 super.onOptionsItemSelected(item);
    switch (item.getItemId()){
        case R.id.category:
            categoryMenuItem();
            break;
        case R.id.transaction:
            transactionMenuItem();
            break;
        case R.id.user_profile:
            userprofileMenuItem();
            break;
        case R.id.action_settings:
            settingMenuItem();
            break;
    }
        return true;
    }
private void categoryMenuItem(){
    new AlertDialog.Builder(this)
            .setTitle("Category")
            .setMessage("This is a Category AlertDialog")
            .setNeutralButton("OK", new DialogInterface.OnClickListener(){

                @Override
                public void onClick(DialogInterface dialog, int which) {

                }
            }).show();
}
private void transactionMenuItem(){
    final AlertDialog show = new AlertDialog.Builder(this)
            .setTitle("Purchase")
            .setMessage("Purchase page will be show")
            .setNeutralButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Intent i = new Intent(MainActivity.this, Purchase.class);
                    // viewTransaction.putExtra(RowId, c.getId());
                    startActivity(i);
                    finish();

                }
            }).show();
}
private void userprofileMenuItem(){
    new AlertDialog.Builder(this)
            .setTitle("Check Transaction")
            .setMessage("Transaction page will be show")
            .setNeutralButton("OK", new DialogInterface.OnClickListener(){
                @Override
                public void onClick(DialogInterface dialog, int which) {
                Intent i = new Intent(MainActivity.this,Transaction.class);
                    startActivity(i);
                }

            }).show();

}
private void settingMenuItem(){
    new AlertDialog.Builder(this)
            .setTitle("Settings")
            .setMessage("This is a Settings AlertDialog")
            .setNeutralButton("OK", new DialogInterface.OnClickListener(){
                @Override
                public void onClick(DialogInterface dialog, int which) {

                }
            }).show();
}

While i click on the purchase menu action button, it show the app has stopped! error, please kindly help, thanks in advance...

The error show while the app stopped

http://ift.tt/1EeJ0q8 http://ift.tt/1S1xxomenter code here

Aucun commentaire:

Enregistrer un commentaire