【问题标题】:Android: Highlighting list items in a ListViewAndroid:突出显示 ListView 中的列表项
【发布时间】:2012-06-24 04:53:38
【问题描述】:

我有一个具有列表视图的应用程序,我想在用户进行该活动时突出显示特定的列表项。

到目前为止,我有一个通用的实现,我正在创建一个 listView 并且我有一个 OnListItemClick 方法。如果有人可以提供如何在列表视图中突出显示特定列表项的示例实现,我将不胜感激。

【问题讨论】:

标签: android android-listview


【解决方案1】:

它应该是自动完成的,否则你可以做我在这里写的:How can I highlight the table row on click ?

Adapter.getView() 方法中将要膨胀的视图的背景设置为 android:background="@android:drawable/list_selector_background"...

【讨论】:

  • 我不想在点击它时突出显示它。每当我进入该屏幕时,我想突出显示列表视图中的第二个列表项。
  • 啊,比在您的适配器中执行以下操作:if(position == 1 || item.equals(itemToHighlight)) //not sure if you want to do it by position or the item itself, its up to you, remove one or the other { convertView.setBackground(R.color.highlight_color); { else { convertView.setBackground(android.R.color.transparent); }
猜你喜欢
  • 1970-01-01
  • 2013-11-18
  • 2012-06-23
  • 2011-08-16
  • 2013-02-04
  • 1970-01-01
  • 2017-02-17
  • 2012-01-05
  • 2017-09-24
相关资源
最近更新 更多