第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

在Android上滾動(dòng)listview時(shí),復(fù)選框未選中

在Android上滾動(dòng)listview時(shí),復(fù)選框未選中

牧羊人nacy 2019-09-02 20:32:22
我是Android開發(fā)的新手。我listview用a textbox和創(chuàng)建了一個(gè)checkbox。當(dāng)我檢查checkbox并向下滾動(dòng)以檢查列表視圖中的其他項(xiàng)目時(shí),將取消選中較舊的項(xiàng)目。我如何避免這個(gè)問題listview?請(qǐng)引導(dǎo)我使用我的代碼。這是代碼:main.xml中:<?xml version="1.0" encoding="utf-8"?><LinearLayout    xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical"    android:layout_width="fill_parent"    android:layout_height="fill_parent">    <TextView        android:id="@+id/TextView01"        android:layout_height="wrap_content"        android:text="List of items"        android:textStyle="normal|bold"        android:gravity="center_vertical|center_horizontal"        android:layout_width="fill_parent"/>    <ListView        android:id="@+id/ListView01"        android:layout_height="250px"        android:layout_width="fill_parent"/>    <Button        android:text="Save"        android:id="@+id/btnSave"        android:layout_width="wrap_content"        android:layout_height="wrap_content"/></LinearLayout>這是我用來創(chuàng)建動(dòng)態(tài)列表行的XML頁面:listview.xml:<?xml version="1.0" encoding="utf-8"?><LinearLayout    xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_height="wrap_content"    android:gravity="left|center"    android:layout_width="wrap_content"    android:paddingBottom="5px"    android:paddingTop="5px"    android:paddingLeft="5px">    <TextView        android:id="@+id/TextView01"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:gravity="center"        android:textColor="#FFFF00"        android:text="hi"/>    <TextView        android:text="hello"        android:id="@+id/TextView02"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginLeft="10px"        android:textColor="#0099CC"/></LinearLayout>這是我的活動(dòng)課。請(qǐng)幫我解決這個(gè)問題。我在很多地方都提到了這個(gè)問題。但我無法得到正確答案來解決這個(gè)問題。請(qǐng)?zhí)峁┐a以避免在向上和向下滾動(dòng)時(shí)取消選中復(fù)選框。
查看完整描述

3 回答

?
茅侃侃

TA貢獻(xiàn)1842條經(jīng)驗(yàn) 獲得超22個(gè)贊

在自定義listview適配器中,調(diào)用setOnCheckedChangeListener 之后調(diào)用setChecked 。

這樣,您可以從循環(huán)視圖中切斷與舊偵聽器的鏈接。


查看完整回答
反對(duì) 回復(fù) 2019-09-02
?
慕俠2389804

TA貢獻(xiàn)1719條經(jīng)驗(yàn) 獲得超6個(gè)贊

大段引用


**在Side getView()方法中只需調(diào)用>>


check.setOnCheckedChangeListener(new OnCheckedChangeListener() {


            @Override

            public void onCheckedChanged(CompoundButton arg0, boolean arg1) 

            {


                if(check.isChecked())

                {

                    //checked

                    chkArray[position]=true;

                }

                else

                {   //uncheck

                  chkArray[position]=false;


                }

            }

        });


//check condition for checkboxes

        if(chkArray.length>0)

        {

            for (int i = 0; i < chkArray.length; i++) 

            {

                if(chkArray[position]!=null && chkArray[position])

                {

                    check.setChecked(true);

                }

            }

        }


查看完整回答
反對(duì) 回復(fù) 2019-09-02
  • 3 回答
  • 0 關(guān)注
  • 636 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)