Res/menu/
Código XML:
Ver original
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/menuAcercaDe" android:icon="@drawable/ic_menu_about"> </item> <item android:id="@+id/menuQuit" android:icon="@drawable/ic_menu_quit"> </item> </menu>
Código Java:
Código Java:
Ver original
package es.pruebas.menu; import android.app.Activity; import android.view.Menu; import android.view.MenuItem; import android.widget.Toast; public class MenuInflater extends Activity { @Override // TODO Auto-generated method stub android.view.MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menuprincipal, menu); return super.onCreateOptionsMenu(menu); } @Override // TODO Auto-generated method stub int id = item.getItemId(); if (id == R.id.menuAcercaDe) { Toast.makeText(getApplicationContext(), aboutTxt, Toast.LENGTH_LONG).show(); return true; } else if (id == R.id.menuQuit) { finish(); return true; } else { return false; } } }