ViewRootImpl: ViewPostImeInputStage processPointer 0 on OnItemClick of Listview in android
Asked Answered
F

4

41

I have a cart_layout like this:

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ListView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="9"
        android:id="@+id/cart_listview"
        android:layout_gravity="center_horizontal"
        android:background="@color/whiteBg"/>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:layout_gravity="bottom"
        android:padding="5dp"
        android:gravity="bottom"
        android:background="@color/whiteBg">
        <!-- this layout contains a button and a textview which I don't think is the problem -->
    </LinearLayout>
</LinearLayout>

And the java code for it in Cart.java :

protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.cart_layout);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    dbhandler = new DatabaseHandler(this);
    product_all = dbhandler.getProduct();
    total = (TextView)findViewById(R.id.cart_total_textview);

    listview = (ListView)findViewById(R.id.cart_listview);
    
    cart_adapter = new Custom_Cart_Adapter(this,product_all);
    listview.setAdapter(cart_adapter);
    
    listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.v("ITEM CLICK","CLICKED ITEM POSITION: "+position);
            Intent intent = new Intent(Cart.this, Item_edit_details.class);
            intent.putExtra("the_product", product_all.get(position));
            startActivity(intent);
        }
    });
}

I just want to make an OnItemClick event but everytime I tap the item, even when the listview.setOnItemClickListener is there or not, Logcat shows

ViewRootImpl: ViewPostImeInputStage processPointer 0

ViewRootImpl: ViewPostImeInputStage processPointer 1

and nothing happens.

I also see a strange log like this, sometime it said "true" sometime it said "false":

ActivityThread: updateVisibility : ActivityRecord{3308191 token=android.os.BinderProxy@c7ed098 {com.iwant.namhhgames.newiwant/com.iwant.namhhgames.newiwant.Listing_items}} show : false

I don't know if it related to the problem, and I have no idea when the problem occurs, maybe after I messed something up.

And the Logcat is shown for real device only. With AVD, there is nothing shown.

Thank you for your valuable time.

Frazier answered 1/5, 2016 at 17:28 Comment(8)
same issue here. very stramgePruett
app freezes also when i click the buttonPruett
and when I press back the app unfreeezes.Pruett
same issue here too. Any solutions?Dismissal
any solution yet?Ferretti
What SDK min and max and version on Android Studio are you guy using? I for this error implementing Facebook Login with an updated app from min sdk=10, target sdk=15, Android Studio 2.2Chammy
You need to post more code, since the parts that are present seem to work fine in Hicham Pirhano's answer. The problem could be that your adapter returns false in isEnabled(int position) or you have set listView.setEnabled(false) or you set touch listener that returns true to your listview, or some other view somehow consumes your click.Kovach
I am having this problem, and I am just setting my Activity content view to an empty FrameLayout.Bombardon
P
1

this run without issue so maybe your adapter

   @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.testlist);

        ListView listview = (ListView)findViewById(R.id.listest);

        ArrayList<String> cart_adapter = new ArrayList<String>();

        cart_adapter.add("Me");
        cart_adapter.add("Him");
        cart_adapter.add("You");

        listview.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,cart_adapter));

        listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Log.e("ITEM CLICK","CLICKED ITEM POSITION: "+position);
            }
        });

    }

11-16 14:55:31.735 1915-1915/ca.dti.grounded.app E/ITEM CLICK: CLICKED ITEM POSITION: 2 11-16 14:55:34.233 1915-1915/ca.dti.grounded.app E/ITEM CLICK: CLICKED ITEM POSITION: 0 11-16 14:55:35.616 1915-1915/ca.dti.grounded.app E/ITEM CLICK: CLICKED ITEM POSITION: 1 11-16 14:55:36.061 1915-1915/ca.dti.grounded.app E/ITEM CLICK: CLICKED ITEM POSITION: 2

Portentous answered 16/11, 2016 at 20:57 Comment(0)
P
1

You don't list Custom_Cart_Adapter.java. Try to add android:focusable="false" in your single_item.xml which you use inside Custom_Cart_Adapter.java It can help.

Pendentive answered 21/8, 2017 at 6:8 Comment(0)
C
1

The onItemClickListener from listview should not be used as it can cause many issues as this. For this case, I would suggest the use of a custom click listener on the adapter's view and passing the index through this click listener, I mean, try to implement your own onItemClickListener.

As you may notice, at recyclerView the onItemClickListener doesn't appear and the proper approach is to implement your own onItemClickListener.

Confucian answered 20/12, 2017 at 10:41 Comment(0)
P
0

You did right but for arrayadapter your onItemClick() listener should be look like this.

ListView listview = (ListView)findViewById(R.id.listest);
   listview .setOnItemClickListener(new OnItemClickListener()
   {
      @Override
      public void onItemClick(AdapterView<?> adapter, View v, int position,
            long arg3) 
      {
            Log.e("ITEM CLICK","CLICKED ITEM POSITION: "+position);
      }
   });

Hope it will help you!!

Pilau answered 26/4, 2018 at 5:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.