2011-09-15 8 views
0

私は多くの検索をしていますが、listView内のアイテムは直線レイアウトであり、すでにandroid:descendantFocusable="blockDescendants"を追加していますが、機能しません。listview、onItemClickListenerは機能しません

私はアダプタでオーバーライドgetView()と言い、ビューにonCLickListenerを追加すると、それが動作するかどうかはわかりませんが、onItemClickListenerは動作しません。

setOnItemSelectedListenerはうまく動作します。手がかりを得ることはできません。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="horizontal" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:background="@drawable/item_style" 
android:focusable="true" 
android:descendantFocusability="blocksDescendants"> 
<ImageView 
    android:id="@+id/dialog_item_type" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:paddingLeft="5dp" 
    android:focusable="false" 
    /> 
<TextView android:layout_weight="1" 
    android:id="@+id/dialog_item_name" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:padding="5dp"  
    android:textStyle="bold" 
    android:textColor="#FFFFFFFF" 
    /> 

<ImageView 
    android:id="@+id/dialog_item_sel" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:paddingRight="5dp" 
    /> 

private class FileListView extends ListView{ 
    private List<Map<String, Object>> tempShowList ; 
    public FileListView(Context context) { 
     super(context); 
     this.setSelector(R.drawable.item_unfocus); 
     this.setItemsCanFocus(true); 
     this.setClickable(true); 
     this.setOnItemClickListener(new OnItemClickListener() { 

      public void onItemClick(AdapterView<?> adapterView, View arg1, 
        int position, long arg3) { 
         Log.e("on item click","here"); 
        } 
    } 
} 
+0

あなたはbeforeDescendantsを試しましたか? –

+0

あなたはandroid:descendantFocusability = beforeDescendantsと言っていますか?これを設定しないでください。私は無駄に何かを設定しようとしなかった。 @Yashwanth Kumar – zyunchen

+0

私はbeforeDescendants.in無駄に試してみました。 – zyunchen

答えて

1

私はすでにこの問題を解決する方法を知っています。私はアダプターのgetView()メソッドでアダプターmyself.Andを記述しています。ビューをクリック可能に設定しました。これはこの問題を引き起こす。このアクションを処理しないときにクリックアクションが最初に子ビューで処理されるため、その親は後でそれを処理します。

関連する問題