2012-12-04 26 views
0

我有一個ListView的問題。我會嘗試識別當我點擊(觸摸)一個listview項。我嘗試了setOnItemClickListener,但只能使用鍵盤。如何識別鼠標點擊listview項目?

我該怎麼辦?什麼不好?

編輯:我使用ListActivity。並使用onListItemClick,但是當我用鼠標點擊AVD時,不工作。

編輯2:我使用自定義列表視圖,包含一個TextView和ImageView的

<LinearLayout android:id="@+id/lista" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    > 

    <ListView android:id="@android:id/list" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:divider="#b5b5b5" 
     android:dividerHeight="3dp" 
     > 

    </ListView> 
    </LinearLayout> 



<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/texto" 
     android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:textSize="15dp" 
    android:textStyle="bold" 
    android:gravity="left" 
    android:padding="5dp" 
    android:paddingBottom="5dp" 
    android:text="@string/texto" 
    /> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     > 
     <ImageView 
      android:id="@+id/btn_imagen" 
      android:scaleType="center" 
      android:layout_width="match_parent" 
      android:layout_height="150dp" 
      android:src="@drawable/logo" 
      android:contentDescription="@string/Imagen"/> 

    </LinearLayout> 
</LinearLayout> 
+1

您是否使用常規的「活動」或「ListActivity」?如果您在列表單元格視圖中有偵聽器,請發佈您的偵聽器 – mango

+0

,您可能正在使用事件,請嘗試在其上返回false。嘗試將'onTap'事件記錄到ListView – thepoosh

回答