私はカスタムListViewの電話連絡先をロードしています。各行はCheckedTextViewと別のTextViewを含むチェック可能なLinearLayoutです。getView内のCheckedTextViewをチェック/チェック解除できません
私はリストビューにカスタムArrayAdapterを与えています。私の問題は、getView()内のCheckedTextViewsを制御できないことです。例えば、私は、リストビューをスクロールするたびに、すべてのテキストビューをチェックすることになっています
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
if(row == null){
row = inflater.inflate(layout, parent, false);
}
CheckedTextView checkedTextView = (CheckedTextView) row.findViewById(R.id.checkedTextView);
checkedTextView.setText("A");
checkedTextView.setChecked(true);
return row;
}
次試みるが、それは起こっていないとき。誰も私にそれをする方法を教えてもらえますか?
EDIT:それは(getViewメソッドの内部でそれを確認することが重要です)、私はちょうどsetListAdapter()
EDIT2後にすべてをチェックすることはできません。これは、各行
<?xml version="1.0" encoding="utf-8"?>
<com.example.multiplecontacts.CheckableLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<CheckedTextView
android:id="@+id/checkedTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:paddingBottom="0dp"
android:text="CheckedTextView"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/subTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Small Text"
android:paddingTop="0dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
</com.example.multiplecontacts.CheckableLinearLayout>
の見解を示したXMLファイルです
CheckableLinearLayoutは、LinearLayoutを拡張し、前述のCheckableを実装するカスタムレイアウトです。そして、私はそれを取ったhere
、活動から
/断片は、デフォルトでチェックされます。実際には上記のコードは私の実際のコードではなく、私の問題を示す単なるサンプルです。私が必要とするのは、getView()内のCheckedTextViewを切り替えることです。 –
xmlを投稿してください。 –
'checkbox'でレイアウトを取得しましたが、' checkbox'を押してもチェックされません。 –