Android 单击按钮后 sendUserActionEvent() mView== null
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20160737/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
sendUserActionEvent() mView== null after clicking on button
提问by akshay
I have checked with this linkbut there its mentioned about long clicks. but I am facing this after clicking on button of custom dialog. I have pasted my code over here. can anyone help me to avoid this error.
我已经检查过这个链接,但它提到了长点击。但是在单击自定义对话框的按钮后我正面临这个问题。我已经把我的代码贴在这里了。谁能帮我避免这个错误。
ibtnCancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.w("DemoDvicetracker", etConfirmPassword
.getText().toString());
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(
etConfirmPassword.getWindowToken(), 0);
passwordPopup.dismiss();
}
});
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rel"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:background="@drawable/popup_bg" >
<TextView
android:id="@+id/txt_enter_pwd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/enter_pwd"
android:textSize="24sp"
android:textColor="@android:color/black" />
<EditText
android:id="@+id/et_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_enter_pwd"
android:hint="@string/pwd"
android:background="@drawable/popup_textfeild"
android:layout_marginTop="30dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:inputType="textPassword"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="60dip"
android:layout_alignParentBottom="true"
android:layout_below="@+id/et_password"
android:gravity="bottom"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/ibtn_dialog_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/popup_cancel_selector"
android:contentDescription="@string/cancel"/>
<ImageButton
android:id="@+id/ibtn_dialog_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_weight="1"
android:background="@drawable/popup_submit_selector"
android:contentDescription="@string/submit"/>
</LinearLayout>
回答by Seynorth
this is not a problem related to your code, but related to S4 android version. Same question has been posed on stackoverflow : sendUserActionEvent() is null
这不是与您的代码相关的问题,而是与 S4 android 版本相关的问题。在 stackoverflow 上也提出了同样的问题:sendUserActionEvent() 为空
So, just ignore it ;)
所以,忽略它;)
回答by dianakarenms
In my case I was using al this intent flags together to intent the activity:
在我的情况下,我将所有意图标志一起用于意图活动:
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
Just left the clear_top flag and it solved the problem:
刚刚离开 clear_top 标志,它解决了问题:
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);