【问题标题】:Change color of end of record in ListView更改 ListView 中记录结尾的颜色
【发布时间】:2016-06-23 12:18:18
【问题描述】:

是否可以更改 listView 中滚动结束的颜色。当我滚动到 listview 的末尾或 listView 的开头时,滚动结束的顶部和底部会出现白色。我可以改变那个颜色吗?

谢谢!

【问题讨论】:

  • 向我们展示您的尝试?

标签: android xml listview android-studio scrollview


【解决方案1】:

要改变最后一项的颜色,

if (position == list.length - 1) {
    holder.title.setTextColor(Color.RED);
}else{   
    holder.title.setTextColor(Color.BLACK);
}

【讨论】:

    【解决方案2】:

    您可以在您的适配器 getview 函数中执行此操作,每次在屏幕上显示新的 listview 项目时都会调用 getview 函数。在 getview 函数中添加 if else 语句

    if(position == 0 || position == getCount()){
       // change to the color you want to change
    } else {
      // change back to the normal color
    }
    

    【讨论】:

      猜你喜欢
      • 2017-02-04
      • 2015-06-22
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多