Guest User

Untitled

a guest
Jul 16th, 2019
68
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import android.support.v7.app.AppCompatActivity;
  2. import android.os.Bundle;
  3. import android.view.Menu;
  4. import android.view.MenuItem;
  5. import android.widget.Toast;
  6.  
  7. public class MainActivity extends AppCompatActivity {
  8.  
  9. @Override
  10. protected void onCreate(Bundle savedInstanceState) {
  11. super.onCreate(savedInstanceState);
  12. setContentView(R.layout.activity_main);
  13. }
  14.  
  15. //Método para mostrar y ocultar el menú
  16. public boolean onCreateOptionsMenu(Menu menu){
  17. getMenuInflater().inflate(R.menu.overflow, menu);
  18. return true;
  19. }
  20.  
  21. //Método para asignar las funciones correspondientes a las opciones.
  22. public boolean onOptionsItemSelected(MenuItem item){
  23. int id = item.getItemId();
  24.  
  25. if(id == R.id.item1){
  26. Toast.makeText(this, "Opción 1", Toast.LENGTH_SHORT).show();
  27. } else if(id == R.id.item2){
  28. Toast.makeText(this, "Opción 2", Toast.LENGTH_SHORT).show();
  29. }else if(id == R.id.item3){
  30. Toast.makeText(this, "Opción 3", Toast.LENGTH_SHORT).show();
  31. }
  32. return super.onOptionsItemSelected(item);
  33. }
  34. }
  35.  
  36. 1- click en el menu Build
  37. 2- click en Clean Project
  38. 3- click en Build Project
  39.  
  40. 1- click en el menu File
  41. 2- Invalidates Cache /restart
RAW Paste Data