2014-07-16 67 views
3

我有一個小的Android應用程序與它的列表視圖。有時候,listview對我的輸入沒有反應。我可以看到,我觸及了一個項目(它改變了我觸摸它的顏色),但該程序什麼都不做。 這是我的XML文件:Android的ListView OnItemClickListener有時不工作

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/LinearLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:focusable="false" 
    android:focusableInTouchMode="false" > 

    <TextView 
     android:id="@+id/textViewRowLable" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp" 
     android:textSize="50sp" /> 

    <TextView 
     android:id="@+id/textViewTime" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_toRightOf="@id/textViewRowLable" 
     android:gravity="right" 
     android:textSize="25sp" /> 

    <TextView 
     android:id="@+id/textViewRemainingTime" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_below="@id/textViewTime" 
     android:layout_toRightOf="@id/textViewRowLable" 
     android:gravity="right" 
     android:textSize="25sp" /> 

</RelativeLayout> 

這是讀心人:

.setOnItemClickListener(new AdapterView.OnItemClickListener() { 

        @Override 
        public void onItemClick(AdapterView<?> parent, View view, 
          int position, long id) { 
         Toast.makeText(getApplicationContext(), "click", Toast.LENGTH_LONG).show(); 
        } 

       }); 

可能有人給我一個提示,爲什麼它不總是工作?

謝謝您RelativeLayout 通過本教程還去使用android:descendantFocusability="blocksDescendants"

回答

0
+0

問題仍然存在。 10個觸摸中有2個未被該應用注意到。我不知道爲什麼。 – MasterCrumble

+0

我有同樣的問題,並沒有弄清楚。你是否發現造成這種行爲的根源?謝謝。 –

相關問題