2016-01-23 40 views
-2

我有popupView的列表視圖與行有一個TextView和ImageView,並點擊它啓動另一個popupView與另一個列表視圖。在我的SGS4和更高版本的API上都像魅力一樣工作......在4.1.1上啓動AVD API 16測試我的應用程序,並且唯一的問題是應用程序的問題是OnItemClick方法,它不起作用。ListVew SetOnItemClickListener不起作用

檢查了StackOverflow並嘗試了所有XML屬性:clickable,focusable,descendantFocusability ...在根視圖,textViews,listView中,沒有成功的所有選項。

任何提示嘗試一下?

XML ListeView佈局:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:id="@+id/headerLayout" 
     android:layout_width="match_parent" 
     android:layout_height="30dp" 
     android:orientation="horizontal" 
     android:layout_alignParentTop="true" 
     android:gravity="center"> 

     <TextView 
      android:layout_gravity="center" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Select your items in Group" 
      android:textColor="@color/colorPrimaryDark" 
      android:textStyle="bold" 
      android:layout_margin="5dp" /> 
    </LinearLayout> 

    <ListView 
     android:id="@+id/lwMain" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_margin="5dp" 
     android:layout_below="@id/headerLayout" 
     android:paddingBottom="50dp" 
     android:layout_marginBottom="0dp"/> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:orientation="vertical" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:layout_marginBottom="5dp"> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="35dp" 
      android:text="OK" 
      android:id="@+id/BtnMain" 
      android:background="@drawable/login_button" 
      android:textColor="@color/colorPrimaryDark" 

      android:layout_gravity="right" /> 
    </LinearLayout> 

</RelativeLayout> 

行佈局XML:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/title" 
     android:textColor="@color/Gray" /> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/imageView" 
     android:layout_gravity="right" 
     android:src="@drawable/abc_ic_go_search_api_mtrl_alpha" /> 


</LinearLayout> 

編輯:

只是說,我對其他活動的另外一個列表視圖工作正常。像這裏一樣的代碼。同樣itemclicklistener ..

+0

顯示您的代碼請 –

+0

如果您顯示代碼/ –

+0

我們只能提供幫助僅需一秒鐘,我就會添加listview和Row佈局的XML。 – Sasaman

回答

0

我設法解決這個...

我有setFocusable(false)setTouchable(true),我把他們趕走,並開始工作。因爲第一個listview只有沒有checkbox的項目。第二個有相同的參數,但複選框和第二個工作。 也許有人會有同樣的問題。我的解決方案就是這樣

相關問題