How to set ListView selected item alternet text color in android

前端 未结 5 1266
猫巷女王i
猫巷女王i 2021-01-07 01:31

I have a custom listview with a imageview and an textview. I want when user select a item the textview color should change and all the other textview should remain default.<

5条回答
  •  一整个雨季
    2021-01-07 02:04

    For that you've to set OnClickListener for that particular ImageView and then change TextView's color on click of ImageView in Adapter Class.
    Alternatively,

    mList.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView parent, View view, int pos, long id) {
                TextView tv= view.findViewById(resID); 
                tv.setTextColor(color)
            }
        });
    

提交回复
热议问题