我在Dialog中创建菜单时遇到问题。在我的第一个活动中,我有ListView,当onItemLongClick调用菜单的菜单之一并尝试显示对话框时,对话框不包含菜单。
public class ShowMenuDialog extends Dialog {
public enum Mode {
ProjectMenu,
}
private int ProjectID;
private Mode mode_;
public ShowMenuDialog(Context context, Mode mode, int ProjectID) {
super(context);
this.ProjectID_ = ProjectID;
this.mode_ = mode;
}
public ShowMenuDialog(Context context) {
super(context);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.showmenudialog);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = new MenuInflater(this.getContext());
inflater.inflate(R.menu.listviewmenu, menu);
return true;
}
}
showmenudialog.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="265dp"
android:orientation="vertical"
android:layout_height="300dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000"
android:id="@+id/ddd" />
</LinearLayout>
加载对话框菜单后没有显示!!!