There are two buttons 1. Patient and 2. Doctor……. on clicking each of these popup menu appears….. then i added this onOptionsItemselected but it doesn't work at all…… nothing happens when i click the buttons under popup menu
here the java code…
public void onClickingPatient(View view){ PopupMenu popup = new PopupMenu(this,view); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.main_menu,popup.getMenu()); popup.show(); }
public void onClickingDoctor(View view){ PopupMenu popup = new PopupMenu(this,view); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.doctor_menu,popup.getMenu()); popup.show(); }
@Override public boolean onOptionsItemSelected(MenuItem item){ switch(item.getItemId()) { case R.id.loginAsPatient: View viewCurrent = LayoutInflater.from(MainActivity.this).inflate(R.layout.activity_login_details, null); AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setMessage("Login Here"); builder.setView(viewCurrent); break; case R.id.loginAsDoctor: break; } return false; }
11 Comments
Please keep font size bigger.
Sir, please make a video on making a app browser please sir.
how do i do this with fragments ? stackoverflow answers did not help.. just cant get them to work
Sir is this also the another way to create menu?
plz make videos on network discovery and wifi p2p
Is this the only way to create a menu? I was looking for a more standard group of buttons to switch between activities.
package com.example.user.alertview;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;
public class Menu extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
}
@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.activity_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.Settings:
Toast.makeText(this, "now you configure", Toast.LENGTH_SHORT).show();
return true;
case R.id.about:
Toast.makeText(this, "Dhwnia", Toast.LENGTH_SHORT).show();
return true;
case R.id.contact:
Toast.makeText(this, "Sah", Toast.LENGTH_SHORT).show();
return true;
}
}
}
I got error to get intent
Solution?
There are two buttons 1. Patient and 2. Doctor……. on clicking each of these popup menu appears….. then i added this onOptionsItemselected but it doesn't work at all…… nothing happens when i click the buttons under popup menu
here the java code…
public void onClickingPatient(View view){
PopupMenu popup = new PopupMenu(this,view);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.main_menu,popup.getMenu());
popup.show();
}
public void onClickingDoctor(View view){
PopupMenu popup = new PopupMenu(this,view);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.doctor_menu,popup.getMenu());
popup.show();
}
@Override
public boolean onOptionsItemSelected(MenuItem item){
switch(item.getItemId()) {
case R.id.loginAsPatient:
View viewCurrent = LayoutInflater.from(MainActivity.this).inflate(R.layout.activity_login_details, null);
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setMessage("Login Here");
builder.setView(viewCurrent);
break;
case R.id.loginAsDoctor:
break;
}
return false;
}
nice
i didnt have that menu folder
how to create that
Thumps Up (Y)