我试图创建一个ListPreference但不知何故禁用其中一个项目.有点像灰色或其他东西,没有能力选择它.这将是一个即将推出的功能,我希望它在列表中是不可选择的.
我已经创建了一个自定义ListPreference类,并在该类中自定义适配器,希望使用适配器来创建我想要的.
代码工作,它设置适配器,但没有调用任何适配器函数.我在方法上设置断点,例如getCount()但它们永远不会被调用.
这是我的代码.自定义ListPreference取自http://blog.350nice.com/wp/archives/240
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.preference.ListPreference;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.app.AlertDialog.Builder;
public class CustomListPreference extends ListPreference {
private boolean[] mClickedDialogEntryIndices;
CustomListPreferenceAdapter customListPreferenceAdapter = null;
Context mContext;
public CustomListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
mClickedDialogEntryIndices = new boolean[getEntries().length];
}
@Override
protected void onPrepareDialogBuilder(Builder builder) {
CharSequence[] entries = getEntries();
CharSequence[] entryValues = getEntryValues();
if (entries == null || entryValues …Run Code Online (Sandbox Code Playgroud)