リストビューをclickable.Iできません。同じタイプの質問に対して同じソリューションを試してみました。フォーカス可能な trueableとfalseの両方にフォーカスを変更しようとしました。リストビューの項目をクリック可能にすることができません
ボタンを10/12回クリックした後に動作することがあります(listviewのテキストがクリックされることがあります)。 以下は私のxmlファイルとjavaファイルです。 20回以上押した後に行番号9がクリックされたときにlogcatのスクリーンショットも添付しました。 enter image description here 助けてください..
Activity_card.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rlLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.hppc.business.Card">
<ListView
android:id="@+id/lvUsers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:clickable="true"
android:focusable="false"
android:focusableInTouchMode="false"
android:descendantFocusability="blocksDescendants">
</ListView>
</RelativeLayout>
entry1.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="false"
android:focusableInTouchMode="false"
android:orientation="horizontal"
android:padding="13dp">
<ImageView
android:layout_width="90dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:clickable="true"
android:focusable="false"
android:focusableInTouchMode="false"
android:src="@drawable/image" />
<linearlayout>.....</linearlayout>
</linearLayout>
card.java
あなたはリストビューフォーカス可能を確認する必要があり
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Intent i = new Intent(Card.this, Manual.class);
Log.i("HelloListView", "You clicked Item: " + id + " at position:" + position);
Log.e("YESSSS",Integer.toString(position));
startActivity(i);
}
});
'アンドロイドを削除してみてください:あなたのentry1.xml –
削除でクリッカブル' = "true" をあなたのリストビューのXML-からの最後の4行すなわち、クリック可能、フォーカス可能、タッチモードでフォーカス可能、特にdescendantFocusability –
@JozefDochan大変ありがとうございました。それは働いた –