10
我正在使用ListView,其中一次只能检查一个项目。 这是我的自定义list_row.xml:Android:我如何检查Checked ListView中的特定项目?
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:textSize="20sp"
android:checkMark="?android:attr/listChoiceIndicatorSingle"
/>
我在填充了的onCreate列表()使用普通阵列适配器:
ArrayAdapter<String> myAdapter = new ArrayAdapter<String>(this, R.layout.list_row, strings);
myList.setAdapter(myAdapter);
当显示列表,我希望有,比方说,列表中的第五项显示为已选中。我怎么能这样做呢?我知道CheckedTextView有一个名为setChecked()的函数,但是我怎样才能从列表中获得我的第五项来应用这个函数呢?