首頁 收藏 QQ群
 網(wǎng)站導(dǎo)航

ZNDS智能電視網(wǎng) 推薦當(dāng)貝市場

TV應(yīng)用下載 / 資源分享區(qū)

軟件下載 | 游戲 | 討論 | 電視計(jì)算器

綜合交流 / 評測 / 活動(dòng)區(qū)

交流區(qū) | 測硬件 | 網(wǎng)站活動(dòng) | Z幣中心

新手入門 / 進(jìn)階 / 社區(qū)互助

新手 | 你問我答 | 免費(fèi)刷機(jī)救磚 | ROM固件

查看: 12164|回復(fù): 0
上一主題 下一主題
[案例]

android的checkbox+listview實(shí)現(xiàn)批量刪除

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
發(fā)表于 2013-8-28 16:27 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
95
這幾天正好需要處理關(guān)于列表批量刪除的問題,因此在網(wǎng)上找了大量的資料,但是始終
沒找到什么好的例子。于是針對網(wǎng)上的一個(gè)例子進(jìn)行了修改,最終實(shí)現(xiàn)了批量刪除操作。故
而在此分享一下,以幫助需要的人。
         首先,寫個(gè)item的xml布局,里面放置一張圖片、一個(gè)TextView和一個(gè)CheckBox。要
注意的是,這里設(shè)置了CheckBox沒有焦點(diǎn),這樣的話,無法單獨(dú)點(diǎn)擊checkbox,而是在點(diǎn)
擊listview的條目后,Checkbox會(huì)響應(yīng)操作。
     
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:orientation="horizontal" >                                                                                                <ImageView        android:id="@+id/item_iv"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_gravity="center_vertical"        android:src="@drawable/ic_launcher"/>                                                                                                    <TextView        android:id="@+id/item_tv"        android:layout_width="0dp"        android:layout_height="wrap_content"        android:layout_weight="1"        android:gravity="center_vertical" />                                                                                                <CheckBox        android:id="@+id/item_cb"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:clickable="false"        android:focusable="false"        android:focusableInTouchMode="false"        android:gravity="center_vertical" />                                                                                            </LinearLayout>   
   
注:下面這三句是實(shí)現(xiàn)設(shè)置CheckBox沒有焦點(diǎn)的。   
[size=1em]
[color=rgb(255, 255, 255) !important]?
   
[backcolor=rgb(248, 248, 248) !important]android:clickable="false"   
android:focusable="false"   
[backcolor=rgb(248, 248, 248) !important]android:focusableInTouchMode="false"   
   
</div

上一篇:Android中Surface和SurfaceView的一些理解和總結(jié)
下一篇:Android 定時(shí)器的實(shí)現(xiàn)
您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

Archiver|新帖|標(biāo)簽|軟件|Sitemap|ZNDS智能電視網(wǎng) ( 蘇ICP備2023012627號 )

網(wǎng)絡(luò)信息服務(wù)信用承諾書 | 增值電信業(yè)務(wù)經(jīng)營許可證:蘇B2-20221768 丨 蘇公網(wǎng)安備 32011402011373號

GMT+8, 2024-10-20 05:49 , Processed in 0.062715 second(s), 15 queries , Redis On.

Powered by Discuz!

監(jiān)督舉報(bào):report#znds.com (請將#替換為@)

© 2007-2024 ZNDS.Com

快速回復(fù) 返回頂部 返回列表