2

I'm in the middle of developing a camera app, and what I need to do is provide a list of resolutions compatible with the user's device. Getting that list is no problem, I can just use the getSupportedPictureSizes() method. However the bit I'm stuck on is populating a ListPreference with that list.

The ListPreference is created in an .xml file which is used in my Settings PreferenceActivity by calling addPreferencesFromResource(R.xml.cam_settings). Any ideas how I can make this ListPreference populate using the list of supported picture sizes?

Thanks in advance for any help.

Caffeinated
  • 11,982
  • 40
  • 122
  • 216
William Stewart
  • 841
  • 1
  • 14
  • 27

1 Answers1

3

i guess you need to populate the ListPreference programatically. here is a LINK

Samuel
  • 9,883
  • 5
  • 45
  • 57
  • Thanks Sam that looks like its the right stuff. Would it be possible with this method to just add a single ListPreference to an existing PreferenceScreen created in an .xml. Or will I have to create the entire thing programatically? – William Stewart Sep 20 '11 at 10:17
  • Ok I got it working. I got an instance of the ListPreference by using getPreferenceScreen().findPreference() then did setEntries and setEntryValues in the onCreate method of my PreferenceActivity. Thanks for the help! – William Stewart Sep 20 '11 at 11:21