導航:首頁 > 操作系統 > androidlistview美化

androidlistview美化

發布時間:2024-01-13 21:59:35

1. android listView 怎麼指定項的背景設置

android listview指定項設定背景步驟如下:

  1. 監聽列表項監聽事件,取得被點擊的view,設置為:view.setSelector("true");

2.在適配器塌鎮中,用if-else語句,判斷選擇的列表項設置背景,沒有選中的則默認背景,代碼如下:


java">try{
if(selectItem==position){
messagetitle.setTextColor(android.graphics.Color.BLACK);
messagetime.setTextColor(android.graphics.Color.BLACK);
viewHolder.messagetitle.setText(maps.get(position)
.get("messagetitle").toString());
viewHolder.messagetime.setText(maps.get(position)
.get("messagetime").toString());
convertView.findViewById(R.id.expandable1)
.setBackgroundColor(android.graphics.Color.WHITE);
convertView.findViewById(R.id.expandable1)
.setBackgroundResource(R.drawable.menu_shapeclick);
}else{
messagetitle.setTextColor(android.graphics.Color.WHITE);
messagetime.setTextColor(android.graphics.Color.WHITE);
viewHolder.messagetitle.setText(maps.get(position)
.get("messagetitle").toString());
viewHolder.messagetime.setText(maps.get(position)
孫鬧.get("messagetime").toString());
convertView.findViewById(R.id.expandable1)
.setBackgroundResource(
團凱粗R.drawable.menu_shapeunonclick);
}
}catch(Exceptionex){
ex.printStackTrace();
}
returnconvertView;
閱讀全文

與androidlistview美化相關的資料

熱點內容
容聲冰箱有電壓縮機不工作了 瀏覽:909
linuxsftp查看用戶 瀏覽:392
collectionssort演算法 瀏覽:555
php表單提交mysql 瀏覽:91
pr未知錯誤編譯 瀏覽:820
androidstudio重置 瀏覽:136
波浪理論pdf 瀏覽:23
nx編程視頻教程 瀏覽:862
堅果c6如何安裝app 瀏覽:531
大連app手機專賣店在哪裡 瀏覽:542
安卓機進水怎麼檢測 瀏覽:62
quartus編譯到特別慢 瀏覽:312
中山plc編程兼職 瀏覽:748
程序員經常訪問的網站 瀏覽:662
重啟ubuntu命令 瀏覽:110
程序員蝸居北六環 瀏覽:265
c高質量編程pdf 瀏覽:287
手機app免費伺服器地址 瀏覽:489
java去除回車換行 瀏覽:482
華為s9303交換機限速命令 瀏覽:806