0
我已經創建了兩個對話框,並且我正在用菜單方式激活這些對話框。但是,當我點擊搜索meu選項時,它將與同步菜單選項重疊。我嘗試了一切,但沒有解決方案。任何人都可以告訴我解決方案。Android菜單選項重疊對話框
我的代碼:
@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);
}
put action_menu.xml – 2013-04-24 07:33:17