我想通过按下optionMenu上的按钮来调用Dialog,但我遇到以下错误:
android.view.WindowLeaked:Activity * android.MessageActivity有 泄露的窗口
com.android.internal.policy.impl.PhoneWindow $ {DecorView b1da86e8 V.E ..... R .....我。最初添加的0,0-640,418}
我的代码是:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_item_contact:
myDialog = new Dialog(getActivity());
myDialog.setContentView(R.layout.contactus);
myDialog.setCancelable(true);
etSubject = (EditText) myDialog.findViewById(R.id.etSubject);
etText = (EditText) myDialog.findViewById(R.id.etText);
bSend = (Button) myDialog.findViewById(R.id.bSend);
myDialog.setTitle("contact us");
myDialog.show();
问题是当我将此代码放入onCreateView时没有问题,Dialog显示没有任何错误