GridView item list selector for multiple items not working in Android

后端 未结 5 917
粉色の甜心
粉色の甜心 2021-01-08 01:30

I want to draw selector on long press as shown in the picture. When I do long press on one item, the CAB menu is activated. But the list selector indicator goes off once aft

5条回答
  •  情深已故
    2021-01-08 01:48

    For this you need to change Grid View Item, BackgroundColor on single/long click.

    Below is the reference code, for the same:

    GridView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView parent, View view, int position, long id) {
            mAdapter.setSelected(position,true);                                          
            view.setBackgroundColor(Color.XYZ);
        }
    }
    

    Hope this help's. Thanks.

提交回复
热议问题