• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps ListActivity and specifying different row layouts

I'm trying to create a "settings" activity that consists of what is similar to the home page's settings page: there's big text, smaller text under it, then either a checkbox or a drop down that consists of radio buttons. I've looked at the ListActivity example but I'm not exactly sure what a Cursor is or does, nor what a URI is when creating a Cursor.

I'm already up to the point where I have one layout that consists of a ListView, and 2 different layouts that specify 2 different rows the listview will have. Up to that point I'm not sure how to populate the listview and each row to be a particular layout and then the text inside it.
 
In Eclipse, choose File, New, Android XML File to bring up the XML file dialog. Choose Preference from the choices of what kind of XML file to build and fill in the name of the file.

You can now create your PreferencesActivity preferences. It puts all your preference info in the XML file. Create your new Activity source file based off of PreferencesActivity and in the OnCreate, you just set it to use the xml file:

addPreferencesFromResource(R.xml.user_preferences)

...where user_preferences is the name of your xml file that you created (i.e. user_preferences.xml in this example).

Changes in the PreferencesActivity automatically write to the shared preferences, so you don't even have to worry about loading and saving values unless you're doing something more advanced.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones