基本上我想要的适配器,当我取消的第一个项目中,第二项是“灰色”和无法点击,或禁用。
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if(position == 0) {
//disable.enable push
CheckBox checkBox = (CheckBox) mRoot.findViewById(R.id.cbRowCheckBox);
checkBox.setChecked(!checkBox.isChecked());
mPushEnabled = checkBox.isChecked();
if (mPushEnabled) {
//code for push enabled
//code to let position 1 enabled, i was thinking something along th e lines,
adapter.getposition(1).setEnabled(true);
} else {
//code for push disabled
adapter.getposition(1).setEnabled(false);
}
} else if(position == 1) {
//push notification settings
//open intent
}
}
我在想,我能得到的,其中产品的位置,只是将其设置为false,以setEnabled()
。这是正确的方式吗?如果是这样,我不知道如何定位该项目。如果现在,最好的方法是什么?
您应该使用PreferenceActivity和android:dependency属性。非本地偏好一个非常非常非常非常糟糕的主意 –
我只想知道如何禁用位置0时按下列表位置1 .....我拥有所有其他逻辑在那里。我把它拿出来,所以这将是一个非常长的帖子 – DDukesterman
这正是PreferenceActivity和依赖关系的目的..我只是想确保你不能使用它们,而我仍然不确定 –