Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This problem was very annoying to me, so after implementing Sandor suggestion, i've searched for better solution in the Android Reference, and look what i've found.<br> <a href="http://developer.android.com/reference/android/preference/EditTextPreference.html">EditTextPreference</a> inherits from <a href="http://developer.android.com/reference/android/preference/DialogPreference.html">DialogPreference</a> and this class have the showDialog method, so i've made a new class from EditTextPreference with a show method, and it works like a charme.</p> <p>Here is some code:</p> <pre><code>public class MyEditTextPref extends EditTextPreference { //...constructor here.... public void show() { showDialog(null); } } </code></pre> <p></p> <p>In my settings.xml (wich i use to generate the ActivitySettings Layout) i've added myEditTextPref</p> <pre><code>&lt;package.that.contains.MyEditTextPreferences android:key="myPref" android:title="@string/pref_title" android:summary="@string/pref_summary" android:dialogTitle="@string/dialog_title" android:dialogMessage="@string/dialog_message" /&gt; </code></pre> <p></p> <p>And the last thing i've done is the onSharedPreferenceChanged method in the PreferenceActivity</p> <pre><code>public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equalsIgnoreCase(MY_CHECK_BOX)) { MyEditTextPreferences myPref = (MyEditTextPreferences) findPreference("myPref"); myPref.show(); } } </code></pre> <p>ps.: actually i'm not using PreferenceFragment because i want pre-honeycomb compatibility but i don't think this code change much.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload