3

我想在打开首选项屏幕时打开 EditTextPreference。我试试

mLabel = (EditTextPreference) findPreference("labelKey");
mLabel.getDialog().show() // this does not work. getDialog return null
mLable.getEditText().requestFocus(); // this does not work too.

我怎样才能做到这一点?

4

1 回答 1

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 ); 
于 2012-06-06T10:40:00.647 回答