android listview item点击时更改textview的颜色 代码中实现
2019獨角獸企業重金招聘Python工程師標準>>>
listview點擊時更改textview文字顏色很多網上的資料都已經介紹,本人也在實際中xml文件中已實現。
但是將xml文件中設置的textcolor放到代碼就確不起作用了,目前仍未找到原因,希望知道原因的大神指點下。
不過經過一天的努力還是找到了解決辦法,就是自定義按鈕文字變色類
ColorStateList
代碼:
new ColorStateList(
??????????????? new int[][]{
??????????????????????? new int[]{android.R.attr.state_pressed}, //1
??????????????????????? new int[]{-android.R.attr.state_focused}, //2
??????????????????????? new int[]{android.R.attr.state_selected, android.R.attr.state_pressed} //3
??????????????? },
??????????????? new int[] {
??????????????????? Color.GREEN, //1
??????????????????? Color.WHITE, //2
??????????????????? Color.BLUE //3
??????????????? }
??????????? );
然后設置 .setTextColor(myColorStateList);就可以了
轉載于:https://my.oschina.net/u/992018/blog/267400
總結
以上是生活随笔為你收集整理的android listview item点击时更改textview的颜色 代码中实现的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 《cocos2d-x手机游戏开发实战》直
- 下一篇: Iperf源代码分析(八)