@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater=getMenuInflater();
menuInflater.inflate(R.menu.menu1,menu);
return super.onCreateOptionsMenu(menu);
}
Escoger Opción del Menu
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()){
case R.id.item1:
Toast.makeText(getBaseContext(),"Eligio Item 1",Toast.LENGTH_SHORT).show();
//Intent intent=new Intent(getBaseContext(),Main2Activity.class);
//startActivity(intent);
break;
case R.id.item2:
finish();;
break;
}
return super.onOptionsItemSelected(item);
}
Multidioma en la Aplicación Android Studio
valores STRING español
<string name="titulo">Aplicación Android</string>
<string name="t1">Guardar</string>
<string name="t2">Salir</string>
valores STRING ingles
<string name="app_name">menues</string>
<string name="titulo">App Android</string>
<string name="t1">Save</string>
<string name="t2">Exit</string>
Boton Atras
public void atras(View view){
Intent intent = new Intent(getApplicationContext(),
MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}