アプリに次の項目レイアウトの GridView があります。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@android:drawable/list_selector_background" >
<TextView
android:id="@+id/notizenTitel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Titel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<TextView
android:id="@+id/notizenBeschreibung"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Beschreibung" />
</LinearLayout>
ユーザーがクリックした場合にアイテムを選択したいと思います。私はこのコードで試しました:
gv.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE);
gv.setOnItemClickListener(this);
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
GridView gv = (GridView) getView().findViewById(R.id.notizenGrid);
gv.setSelection(position);
adapter.notifyDataSetChanged();
}
しかし、アイテムをクリックすると、背景がすぐに黄色に変わり、消えます。そのため、アイテムをクリックしている間はセレクターが機能しますが、選択はできません。理由はありますか?