ViewPostImeInputStage ACTION_DOWN
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
此解决方案应该可以解决该冲突。至少这对我有用。干杯!
我遇到了和你一样的问题,我尝试了 portfoliobuilder 的方法,但没有用。
然后我只是对我的代码进行了一些更改,然后它就起作用了。
我只是将按钮的每个实例设置为 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 set:
android:focusable="true"
android:focusableInTouchMode="true"
删除它后,第一次点击(和后续点击)工作正常,我不再遇到 ACTION_DOWN 的错误。
当我的一行代码有 -->
时,我收到 ViewPostImeInputStage ACTION_DOWN
消息
if(button.getText().equals("word"))
将 if 语句更正为 -->
后,我得到了所需的输出
if(button.getText().toString().equals("word"))
希望对大家有所帮助。
None 以上解决方案对我有用。非常奇怪的错误,想知道是否某些视图正在拦截触摸事件并破坏它,也许是一些 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>
同样,这是一个丑陋的解决方案,但仍然是一个解决方案。
当我尝试调试我的程序时,我无法找出错误。
我已经初始化了两个按钮并在它们上面使用了 .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
此解决方案应该可以解决该冲突。至少这对我有用。干杯!
我遇到了和你一样的问题,我尝试了 portfoliobuilder 的方法,但没有用。 然后我只是对我的代码进行了一些更改,然后它就起作用了。 我只是将按钮的每个实例设置为 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 set:
android:focusable="true"
android:focusableInTouchMode="true"
删除它后,第一次点击(和后续点击)工作正常,我不再遇到 ACTION_DOWN 的错误。
当我的一行代码有 -->
时,我收到ViewPostImeInputStage ACTION_DOWN
消息
if(button.getText().equals("word"))
将 if 语句更正为 -->
后,我得到了所需的输出if(button.getText().toString().equals("word"))
希望对大家有所帮助。
None 以上解决方案对我有用。非常奇怪的错误,想知道是否某些视图正在拦截触摸事件并破坏它,也许是一些 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>
同样,这是一个丑陋的解决方案,但仍然是一个解决方案。