I have created two dialog and I am shoing those dialog in menu otions. But when I am clicking on search meu option it is overlapping with sync menu option. I have tried everything but no solution. can anybody tell me the solution.
My code:
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.action_menu, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
// Handle item selection
case R.id.Synch:
showDialog(SYNC_ALERT);
return true;
case R.id.searchid:
showDialog(SEARCH_ALERT);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
protected Dialog onCreateDialog(int id)
{
switch (id)
{
case SEARCH_ALERT:
// Create out AlterDialog
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Search");
builder.setCancelable(true);
LayoutInflater inflater = this.getLayoutInflater();
View searchView= inflater.inflate(R.layout.search_dialog, null);
builder.setView(searchView);
Searchtxt = (EditText) searchView.findViewById(R.id.search_text);
builder.setPositiveButton("Search", new searchOkOnClickListener());
builder.setNegativeButton("Cancel", new searchCancelOnClickListener());
AlertDialog dialog = builder.create();
dialog.show();
case SYNC_ALERT:
AlertDialog.Builder alertbuilder = new AlertDialog.Builder(this);
alertbuilder.setMessage("Synchronization");
alertbuilder.setCancelable(true);
LayoutInflater buildinflater = this.getLayoutInflater();
View SyncView= buildinflater.inflate(R.layout.sync_layout, null);
alertbuilder.setView(SyncView);
defaultchkbox = (CheckBox)SyncView.findViewById(R.id.defaultchkbox);
after15mint = (CheckBox)SyncView.findViewById(R.id.after15mint);
afternmint = (CheckBox)SyncView.findViewById(R.id.afternmint);
alertbuilder.setPositiveButton("Save Changes", new syncOkClickListener());
alertbuilder.setNegativeButton("Cancel", new syncCancelClickListener());
AlertDialog alertdialog = alertbuilder.create();
alertdialog.show();
}
return super.onCreateDialog(id);
}