[英]ViewPostImeInputStage ACTION_DOWN
当我试图调试我的程序时,我无法弄清楚错误。
我已经初始化了两个按钮并在它们上使用了 .setOnClickListener。 当用户单击按钮时,他们应该会在 LogCat 上看到调试消息。 但是,每当我单击按钮或单击屏幕上的任何位置时,我都会看到此消息出现:ViewPostImeInputStage ACTION_DOWN。
有谁知道这条消息意味着什么,或者他们是否能解决我的问题?
非常感谢!
ViewPostImeInputStage ACTION_DOWN 是一个错误,发生在罕见的情况下,您的布局被拒绝并且您不再能够点击任何可点击的项目,而是每次按下按钮(并且没有任何操作)都会出现 ViewPostImeInputStage ACTION_DOWN。 解决这个问题的方法很简单,用父元素包装你的布局内容。 所以如果你的xml格式是
<LinearLayout <---root layout
...
<!-- your content -->
</LinearLayout> <-- root layout end
改成
<FrameLayout <---root layout
<LinearLayout <-- parent wrap start
...
<!-- your content -->
</LinearLayout> <-- parent wrap end
</FrameLayout> <-- root layout end
此解决方案应解决该冲突。 至少这对我有用。 干杯!
我遇到了和你一样的问题,我尝试了投资组合构建器的方式,但没有奏效。 然后我只是对我的代码进行了一些更改,然后它就起作用了。 我只是将我的按钮的每个实例设置为 OnlickListener 接口,而不是让我的 Class 实现 View.OnClickListener~
button.setOnclickListener(new View.OnClickListener){
public void onClick(View v){//...
}
}
代替
public YourClass implements View.OnClickListener{...
public void OnClick(View v){
switch(v.getId()){
case://...
break;}}}
我遇到了同样的问题,当我使相对布局可点击(在属性中)时得到纠正。
干杯
第一次单击 RecyclerView 中的 CardView 时,我遇到了这种情况。 结果是 CardView XML 集:
android:focusable="true"
android:focusableInTouchMode="true"
一旦我删除了它,第一次点击(以及随后的点击)工作正常,并且我不再有 ACTION_DOWN 错误。
当我的一行代码出现时,我收到了ViewPostImeInputStage ACTION_DOWN
消息 -->
if(button.getText().equals("word"))
将 if 语句更正为 --> 后,我得到了所需的输出
if(button.getText().toString().equals("word"))
希望它可以帮助某人。
上面的解决方案都没有对我有用。 很奇怪的bug,想知道是不是某个视图拦截了触摸事件并破坏了它,也许是一些appcompat的东西,那边有很多触摸拦截......
无论如何,我解决了在我真正损坏的按钮上添加透明View
并在此视图上添加点击侦听器的问题,非常丑陋但它有效¯\\_(ツ)_/¯
例如,想象一下这个布局中发生的错误:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp">
<Button
android:id="@+id/broken_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="0dp"
android:layout_marginTop="0dp"
android:text="Hello world" />
</RelativeLayout>
我添加了透明视图并设置了点击它。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp">
<Button
android:id="@+id/broken_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="0dp"
android:layout_marginTop="0dp"
android:text="Hello world" />
<View
android:id="@+id/workaround_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/broken_button"
android:layout_alignTop="@+id/broken_button"
android:layout_alignEnd="@+id/broken_button"
android:layout_alignBottom="@+id/broken_button" />
</RelativeLayout>
同样,这是一个丑陋的解决方案,但仍然是一个解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.