我遇到的问题是,从通知进行意图活动后,我的“拒绝”按钮不起作用。奇怪的是,除拒绝按钮外,我所有的按钮都在工作。请帮助
它尝试更改为其他组件,例如可点击的布局,但不幸的是失败了。
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.llAccept:
if (NetworkManager.isConnectToInternet(getActivity())) {
booking("1");
} else {
ProjectUtils.showToast(getActivity(), getResources().getString(R.string.internet_concation));
}
break;
case R.id.llDecline:
ProjectUtils.showDialog(getActivity(), getResources().getString(R.string.dec_cpas), getResources().getString(R.string.decline_msg), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Log.d("declinerespone1","decline1");
decline();
}
}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}, false);
break;
}
}
应单击以触发其功能。这是我的Logcat
W/System.err: java.lang.IllegalStateException: View DecorView@9ee3362[BaseActivity] has already been added to the window manager.
W/System.err: at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:328)
W/System.err: at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
W/System.err: at android.app.Dialog.show(Dialog.java:329)
答案 0 :(得分:0)
在onClick
中,您需要检查单击了哪个按钮,
onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
//button clicked
break;
case DialogInterface.BUTTON_NEGATIVE:
//No button clicked
break;
}
}