Domanda

I want to open EditTextPreference when I open Preference screen. I try

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

How can I do this?

È stato utile?

Soluzione

If I understand you right, you need to open a single preference inside your preference screen as soon as you open your preferences (??).

You might want to have a look at this: 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 ); 
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top