3

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?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Kolesar
  • 1,265
  • 3
  • 19
  • 41

1 Answers1

3

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 ); 
Community
  • 1
  • 1
Ashok Goli
  • 5,043
  • 8
  • 38
  • 68