リスト項目をチェックできるように作成しListView
たいのですが、自分で表示用のレイアウトを作成していて、チェック可能にListView
する方法がわかりません。それで、誰かがいくつかのアドバイスを与えることができますか?以下のコードは、私の質問をより明確に説明します。リストアイテムをチェック可能にしたい場合は、以下のコードを示します。
setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_checked,presidents));
しかし、私のコードがこのようなものである場合はどうですか?その中に他のレイアウトがあります:
ArrayAdapter<String> list = new ArrayAdapter<String>(NotificationView.this,R.layout.friendlist_item, R.id.friend_name,people);
lv.setAdapter(list);
ありがとう..
これがfriendlist_item.xmlです:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView android:id="@+id/friend_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dip"
android:textSize="20dip"
android:textStyle="bold"/>
</LinearLayout>
ここでview.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff">
<ListView android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
</ListView>
<FrameLayout android:id="@+id/FrameLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="horizontal" >
<Button
android:id="@+id/acceptbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.46"
android:text="Accept" />
<Button
android:id="@+id/closebtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.49"
android:text="Close" />
</LinearLayout>
</FrameLayout>
</LinearLayout>