ViewPostImeInputStage ACTION_DOWN

前端 未结 6 1662
抹茶落季
抹茶落季 2020-12-06 05:08

As I\'m trying to debug my program, I can\'t figure out the error.

I have initialized two buttons and used .setOnClickListener on them. When the user clicks the bu

相关标签:
6条回答
  • 2020-12-06 05:11

    I have faced the same issue which was corrected when I made the relative layout clickable(in properties).

    cheers

    0 讨论(0)
  • 2020-12-06 05:13

    None of the solutions above worked to me. Pretty strange bug, wondering if some view is intercepting the touch events and broking it, maybe some appcompat stuff, there is a lot of touch intercepts over there…

    Anyway, I workarounded the problem adding a transparent View over my real broken button and adding the click listener on this view, pretty ugly but it worked ¯\_(ツ)_/¯

    e.g. imagine the error happened in this layout:

    <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>
    

    I added the transparent view and I set the click on it.

    <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>
    

    Again, it is an ugly solution, but still a solution.

    0 讨论(0)
  • 2020-12-06 05:19

    I was getting ViewPostImeInputStage ACTION_DOWN message when a line of my code had -->

    if(button.getText().equals("word"))
    

    I got the desired output after correcting the if statement to -->

    if(button.getText().toString().equals("word"))
    

    Hope it helps someone.

    0 讨论(0)
  • 2020-12-06 05:21

    I got the same problem as yours,and I tried portfoliobuilder's way but it didn't work. And then I just make some changes on my code,then it worked. I just set every instance of my button an OnlickListener interface instead of letting my Class inplements the View.OnClickListener~

    button.setOnclickListener(new View.OnClickListener){
    public void onClick(View v){//...
    }
    }
    

    INSTEAD OF

    public YourClass implements View.OnClickListener{...
    public void OnClick(View v){
    switch(v.getId()){
    case://...
    break;}}}
    
    0 讨论(0)
  • 2020-12-06 05:21

    I had this happen to me on the first click of a CardView inside a RecyclerView. It turns out the CardView XML set:

    android:focusable="true"
    android:focusableInTouchMode="true"
    

    Once I removed that, the first click (and subsequent clicks) worked fine, and I no longer had the error with ACTION_DOWN.

    0 讨论(0)
  • 2020-12-06 05:38

    ViewPostImeInputStage ACTION_DOWN is a bug that occurs stemming from the rare instance where your layout is rejected and you are no longer able to click on any clickable items, and what occurs instead is a ViewPostImeInputStage ACTION_DOWN with every button press (and no action). The solution for this is simple, wrap your layout content with a parent. So if you xml format was

    <LinearLayout <---root layout
    ...
    <!-- your content -->
    </LinearLayout> <-- root layout end
    

    change to

    <FrameLayout <---root layout
       <LinearLayout <-- parent wrap start
       ...
    <!-- your content -->
       </LinearLayout> <-- parent wrap end
    </FrameLayout> <-- root layout end
    

    This solution should resolve that conflict. Atleast this is what has worked for me. Cheers!

    0 讨论(0)
提交回复
热议问题