Hello!

I want to put a ListPreference in my preference screen. But all the examples
I have found in Internet the content are loaded out of a xml and I need that
de options in the ListPreference are dynamic and not previously defined (in
a xml).

I have mi preferences.xml in the folder xml/ of my project;

this is the code of preferences.xml:

<?xml version="1.0" encoding="utf-8"?>

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android
> ">

    <CheckBoxPreference

          android:key="gcalendar_integration"

          android:title="@string/gcalendar_integration"

          android:summary="@string/gcalendar_integration_summary"

          android:defaultValue="false"

          android:persistent="true" />


>      <ListPreference

          android:key="gcalendar_list"

          android:title="lista"

          android:summary="descripcion lista"

          android:persistent="true"

          android:dependency="gcalendar_integration" />



</PreferenceScreen>




and the PreferenceActivity which calls the xml: (i have omitted  the
imports)

public class Preferences extends PreferenceActivity {


>     @Override

    public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

addPreferencesFromResource(R.xml.preferences);

    }

}


But I dont have a clue about how to set the contents of the ListPreference
dynamically at the code. I have seen that the class ListPreference has a
method .setEntries(CharSequence[] list) which is for this purposes but I
don't know how to link an object of the ListPreference at the code with the
ListPreference defined at the xml.

Any idea?

Thanks in advance!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to