android listview item点击时更改textview的颜色 代码中实现
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
listview點(diǎn)擊時(shí)更改textview文字顏色很多網(wǎng)上的資料都已經(jīng)介紹,本人也在實(shí)際中xml文件中已實(shí)現(xiàn)。
但是將xml文件中設(shè)置的textcolor放到代碼就確不起作用了,目前仍未找到原因,希望知道原因的大神指點(diǎn)下。
不過經(jīng)過一天的努力還是找到了解決辦法,就是自定義按鈕文字變色類
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
??????????????? }
??????????? );
然后設(shè)置 .setTextColor(myColorStateList);就可以了
轉(zhuǎn)載于:https://my.oschina.net/u/992018/blog/267400
總結(jié)
以上是生活随笔為你收集整理的android listview item点击时更改textview的颜色 代码中实现的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 《cocos2d-x手机游戏开发实战》直
- 下一篇: PostgreSQL日期函数备忘