Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is nice tutorial for add preferences dynamically...later you have to customized its own way. </p> <p>In XMl :</p> <pre><code>&lt;Preference android:key="key" android:title="See Android Market"&gt;&lt;/Preference&gt; </code></pre> <p>In Java class:</p> <pre><code>Preferences preferences=findPreference("key"); preferences.setIntent(new Intent(Intent.ACTION_VIEW,Uri.parse("https://market.android.com/"))); </code></pre> <p>OR</p> <pre><code>import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.preference.CheckBoxPreference; import android.preference.DialogPreference; import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; import android.widget.LinearLayout; import android.widget.ListView; public class SettingsActivity extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* Some initializations */ LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); ListView listView = new ListView(this); listView.setId(android.R.id.list); listView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT, 1)); layout.addView(listView); this.setContentView(layout); /* Preferences time! (we build the preferences) */ Preference version = getPreference("My School Manager", "Version 2.0",null); Preference author = getPreference("Author", "Balu", null); Preference marketLink = getPreference("Android market","View all my apps :)",new Intent(Intent.ACTION_VIEW, Uri.parse("http://market.android.com/"))); CheckBoxPreference check = new CheckBoxPreference(this); check.setTitle("Checkbox"); check.setSummary("Example of checkbox"); DialogPreference license = new MyDialogPreference(this, "License","This is the license for...bla bla"); /* Now we add the preferences to the preference screen */ PreferenceScreen preferenceScreen = this.getPreferenceManager() .createPreferenceScreen(this); addPreferenceCategory(preferenceScreen, "Preferences Tutorial",version, author, marketLink, check, license); this.setPreferenceScreen(preferenceScreen); } private boolean addPreferenceCategory(PreferenceScreen preferenceScreen, String titleCategory, Preference... preferences) { boolean addPreference = false; for (Preference preference : preferences) { if (preference != null) addPreference = true; } if (addPreference) { PreferenceCategory preferenceCategory = new PreferenceCategory(this); preferenceCategory.setTitle(titleCategory); preferenceScreen.addPreference(preferenceCategory); for (Preference preference : preferences) { if (preference != null) preferenceCategory.addPreference(preference); } return true; } else return false; } private Preference getPreference(String title, String summary, Intent intent) { Preference pref = new Preference(this); pref.setTitle(title); pref.setSummary(summary); if (intent != null) pref.setIntent(intent); return pref; } public class MyDialogPreference extends DialogPreference { public MyDialogPreference(Context context, String title, String text) { super(context, null); this.setTitle(title); this.setDialogMessage(text); } } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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