我打开Preference屏幕时打开EditTextPreference。我试试
mLabel = (EditTextPreference) findPreference("labelKey");
mLabel.getDialog().show() // this does not work. getDialog return null
mLable.getEditText().requestFocus(); // this does not work too.
我该怎么做?
答案 0 :(得分:3)
如果我理解正确,您需要在打开首选项后立即在首选项屏幕中打开一个首选项(??)。
您可能需要查看此内容:https://stackoverflow.com/a/4869034/668240
// the preference screen your item is in must be known
PreferenceScreen screen = (PreferenceScreen) findPreference("pref_key");
// the position of your item inside the preference screen above
int pos = findPreference("abc").getOrder();
// simulate a click / call it!!
screen.onItemClick( null, null, pos, 0 );