Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Android preferences and dont show a variable to user
    text
    copied!<p>I have a sharedPreferences implementation where I store user preferences. When the user clicks "preferences" in menu, I open the standar editor to allow the user to change preferences. This is the code:</p> <pre><code>@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.MENU_PREFERENCES: Intent intent = new Intent(context, PreferencesActivity.class); startActivity(intent); return true; case xx: .... } Toast.makeText(this, "ERROR: Bad menu item", Toast.LENGTH_SHORT).show(); return true; } </code></pre> <p>In PreferencesActivity.java I have:</p> <pre><code>public class PreferencesActivity extends PreferenceActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); } } </code></pre> <p>My question is if can I have a variable in the preferences for internal use, I mean, that will not be showed to user when startActivity(intent)? how?</p> <p>I suppose I must change something in preferences.xml but dont know exactly what....</p> <p>thanks</p> <p>EDIT: as requested, I paste xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;PreferenceCategory&gt; &lt;ListPreference android:title="Pomodoro duration" android:key="pomodoro_duration" android:summary="Duration of each pomodoro" android:entryValues="@array/array_duration_values" android:defaultValue="25" android:entries="@array/array_duration"/&gt;&lt;ListPreference android:key="short_break_duration" android:title="Short break duration" android:summary="Duration of break after each pomodoro" android:entryValues="@array/array_duration_values" android:entries="@array/array_duration" android:defaultValue="5"/&gt; &lt;ListPreference android:title="Long break interval" android:summary="Interval of the longer break" android:key="intervalos" android:entryValues="@array/interval_array_values" android:defaultValue="4" android:entries="@array/interval_array"/&gt; &lt;ListPreference android:defaultValue="20" android:title="Long break duration" android:summary="Duration of break after each pomodoro" android:key="long_break_duration" android:entries="@array/array_duration" android:entryValues="@array/array_duration_values"/&gt;&lt;RingtonePreference android:title="Notification sound" android:ringtoneType="notification" android:summary="Tone that will sound after pomodoro ends" android:key="notification_tone" android:showDefault="true" android:showSilent="true"/&gt; &lt;ListPreference android:summary="Period used to calculate productivity" android:title="Calculus period" android:key="calculus_period" android:entryValues="@array/array_calculo_valores" android:entries="@array/array_calculo"/&gt; &lt;/PreferenceCategory&gt; &lt;/PreferenceScreen&gt; </code></pre> <p>When I inveke the standar UI to allow user to set this variables, I would like to hide one of them programmaticaly. Is possible?</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