2017-06-26 5 views
-2

リストビューを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); 
    } 
}); 
+1

'アンドロイドを削除してみてください:あなたのentry1.xml –

+0

削除でクリッカブル' = "true" をあなたのリストビューのXML-からの最後の4行すなわち、クリック可能、フォーカス可能、タッチモードでフォーカス可能、特にdescendantFocusability –

+0

@JozefDochan大変ありがとうございました。それは働いた –

答えて

0

  android:focusable="true" 
      android:focusableInTouchMode="true" 
+0

助けていただきありがとうございます。私はすでにこれを試していたが、それは私のために働いていませんでした。entry1.xmlでclickableを削除しました。 –

関連する問題