私は1つのリストビューを作成しました。この各行にはチェックボックスとテキストが含まれています。チェックボックスがオン(チェック)のリストのテキストを取得する必要があります。それはチェックボックスを使用して、リストから選択されたテキスト値を渡す必要があります。リストは、私はすべての値を渡す必要があり、この場合アンドロイドのリストのチェックボックスをどのように選択するには?
ように見える
gatwayList = (ListView) findViewById(R.id.gatwaylist);
ArrayList<HashMap<String,String>> wholeDetailsList = new ArrayList<HashMap<String,String>>();
for (int i = 0; i < 5; i++)
{
HashMap<String, String> map = new HashMap<String, String>();
map.put("name", "Test+ i");
//map.put("address", wrap_address);
wholeDetailsList.add(map);
}
SimpleAdapter wholeDetailsAdapter = new SimpleAdapter(this,
wholeDetailsList, R.layout.gatway_row, new String[] {"name"}, new int[] {R.id.gatwayId});
gatwayList.setCacheColorHint(0);
gatwayList.setAdapter(wholeDetailsAdapter);
gatway_row.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<CheckBox
android:id="@+id/check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4px"
android:layout_alignParentLeft="true"
android:layout_marginRight="10px" >
</CheckBox>
<TextView android:id="@+id/gatwayId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ffff"
android:textSize="18dip"
android:layout_marginTop="15dip"
android:layout_marginLeft="60dip"
android:textStyle="bold"
android:textColor="#000000"/>
</RelativeLayout>
:
は、これは私のコードです。それ以外は選択した値のみ。すべてのコメントは高く評価されますか?
@AMRI:上記のコードでは「CHOICE_MODE_MULTIPLE」とは何ですか。また、これは私が期待したようにうまく動作しません。上記のUIと同じUIが必要です。また、チェックボックスをカスタマイズする必要があるので、上記のコードを使用してください。上記のコードを試しましたが、リストから何も選択できませんでした。つまり、チェックボックスは選択できません。 – Lakshmanan