2014-12-25 2 views
0

Я работаю над приложением Android, в котором я создаю пользовательский список, в котором я разместил несколько текстовых просмотров и один переключатель. После включения тумблера он не позволяет клиенту использовать listview. Я также поставил android:focusable="false" в свой XML, но он по-прежнему не позволяет клиенту переходить на просмотр.Toggle Switch in custom listview делает listview неактивным

Мой код и XML приведен ниже:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="#fff" 
    android:gravity="center_vertical" 
    android:clickable="true" 
    android:orientation="horizontal" 
    android:padding="5dp" > 

    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_vertical" 
     android:layout_weight="1" 
     android:orientation="horizontal" > 

     <com.za.views.CircularImageView 
      android:id="@+id/trustNetListUserImageView" 
      android:layout_width="75dp" 
      android:layout_height="75dp" 
      android:layout_marginRight="5dp" 
      android:padding="5dp" 
      android:scaleType="fitXY" 
      android:src="@drawable/profile_" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical" 
      android:orientation="vertical" > 

      <TextView 
       android:id="@+id/trustNetListNameTextView" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:gravity="center_vertical" 
       android:singleLine="true" 
       android:text="hesds" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textColor="#000" /> 

      <TextView 
       android:id="@+id/trustNetListNumTextView" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:singleLine="true" 
       android:text="TextView" /> 

      <TextView 
       android:id="@+id/trustNetListApprovedTextView" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="right|bottom" 
       android:layout_marginRight="3dp" 
       android:gravity="right" 
       android:text="Approved" 
       android:textColor="#ff0077" 
       android:textSize="10sp" /> 

      <Switch 
       android:id="@+id/switch1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:focusable="false" 
       android: 
       android:focusableInTouchMode="false" 
       android:text="Switch" /> 

     </LinearLayout> 
    </LinearLayout> 

</LinearLayout> 


requestListView.setAdapter(adapter); 
requestListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 

@Override 
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) { 

           showLoadingDialog(); 
           ParseObject parseObject = requestedNetArrayList.get(arg2); 
           Constants.setOtherUserId(parseObject.getObjectId().toString()); 
           Intent intent = new Intent(TrustrkActivity.this,Othenfo.class);  
           startActivity(intent); 

           if (parseObject.getBoolean("isApproved")) 
            parseObject.put("isApproved", false); 
           else 
            parseObject.put("isApproved", true); 

           parseObject.saveInBackground(new SaveCallback() { 

            @Override 
            public void done(ParseException e) { 
             populateReqNetwork(); 
            } 
           }); 
          } 
         }); 

ответ

2

Заменить

android:focusable="false" 
android: 
android:focusableInTouchMode="false" 

По

android:focusable="false" 
android:focusableInTouchMode="false" 
2

Try:

android:clickable="false" 
+1

Это связано с добавлением 'android: focusable =" false "и' android: focusableInTouchMode = "false" 'работал для меня – user3280133

+0

, где эта строка идет? – Luminaire

+0

Все три 'android: clickable =" false "', 'android: focusable =" false "', а 'android: focusableInTouchMode =" false "' не работает для меня. Вместе или раздельно. – Nashe

 Смежные вопросы

  • Нет связанных вопросов^_^