2013-03-01 110 views
0

在我的应用程序中,我使用的自定义Listview的行为TextView和CheckBox
现在我想当我检查CheckBox那时各自的行必须Disable(unfocasable)。
应该是什么里面的代码复选框OnCheckedChangeListener
我也试图禁用的RowLayout内监听器,但没有得到成功......
以下是代码我使用适配器的getView方法中当复选框被选中时禁用列表视图行

final RelativeLayout RL=(RelativeLayout)convertView.findViewById(R.id.VTRLmain); 
     check.setOnCheckedChangeListener(new OnCheckedChangeListener() 
     { 
      @Override 
      public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) 
      { 
       if (isChecked) 
       { 
        RL.setEnabled(false); 
        templist.add(getItem(position));//using for another activity 
       } 
      } 
     }); 
+0

把你的所有代码的意思持有人在这里 – 2013-03-01 13:05:53

+0

简单,如果别的可以在这里工作。如果复选框被选中,则不执行任何操作。但这不会禁用行可聚焦 – 2013-03-01 13:08:14

+0

我正在使用另一个列表检查项目..所以什么都不可行 – Pravin 2013-03-01 13:54:22

回答

0

在该适配器有一个名为isEnabled的方法,您可以将其覆盖。试着在你的自定义适配器做

试试这个代码:

@Override 
public boolean isEnabled(int position) { 
if(checkbox1.isChecked()){ 
    return false; 
} 
return true; 
} 
+1

不工作..... – Pravin 2013-03-01 13:41:34

2

给在XML代码为checkbox

android:focusable="false" 

它不会隐藏列表视图textboxs。

并检查应用程序theme

+0

xml代码不重要。适配器类中应该有代码 – Pravin 2013-03-01 13:55:28

相关问题