0

在我的应用程序中,我使用 CustomListview与行作为 TextView 和CheckBox.
现在我希望当我当时检查CheckBox相应的行必须禁用(不可锁定)时。CheckBox OnCheckedChangeListener
中的代码应该是什么我也尝试在 Listener 中禁用 rowlayout 但没有成功... 以下是我在 Adapter 的 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
                }
            }
        });
4

2 回答 2

2

给出 xml 代码checkbox

android:focusable="false"

它不会隐藏列表视图文本框。

并检查应用程序theme

于 2013-03-01T13:24:40.157 回答
0

In the adapter there is a method named isEnabled which you can overide. Try to do in your custom adapter

Try this code:

@Override
public boolean isEnabled(int position) {
if(checkbox1.isChecked()){
    return false;
}
return true;
}
于 2013-03-01T13:07:42.357 回答