Hightlight the ListView row when a contained UI element of row is touched

拜拜、爱过 提交于 2019-12-03 21:42:21
View tempView = null;  // Class Variable to temporary store Clicked Row's view

Method:

 public void onItemClick(AdapterView parent, View v, int position,long id)
{
    listView.setFocusable(true);
    listView.setSelected(true);
    v.setBackgroundColor(Color.LTGRAY); // CHANGE COLOR OF SELECTED ROW HERE>
    selectedId = (int)id;

    if(tempView != null){
        //If row is already clicked then reset its color to default row color
        tempView.setBackgroundColor(Color.TRANSPARENT);

    }
    tempView = v;

}

Hope this helps. Thanks :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!