Using a ListView to create a settings screen in Android?

There’s no need to manually create and format a ListView – there are ways in the API to create Preference screens.

The most obvious is PreferenceActivity.

You can define all your preferences in an XML file, a bit like a layout, and then load them with addPreferencesFromResource() or you can create a number of PreferenceScreen objects in code and populate them with Preference objects that way.

The best thing do would be to look at the API Demos application provided with the Android API. This contains lots of good examples of managing preferences. Here’s how it creates preferences from code and here’s a sample preferences XML file. There are other examples showing more advanced things like preference dependencies and preference listeners.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)