Bam*_*boo 1 events android listview highlighting onclick
我想启用触摸listView行时出现的橙色突出显示.
如果onclick事件是从行本身生成的,我可以通过设置listview的样式来调整hightlight.但是在我的情况下,click事件是由下面的TextView生成的,附带onclick事件.
触摸事件发生时,Listview不知道发生了点击.它没有收到重点或压力事件.
我可以像Flex一样使用冒泡或捕捉技术吗?或任何建议/解决方案?
非常感谢你.
Piy*_*tel 10
View tempView = null; // Class Variable to temporary store Clicked Row's view
Run Code Online (Sandbox Code Playgroud)
方法:
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;
Run Code Online (Sandbox Code Playgroud)
}
希望这可以帮助.谢谢 :)
| 归档时间: |
|
| 查看次数: |
861 次 |
| 最近记录: |