SyntaxHighlighter JS


Android ListView Tutorial: simple_list_item_1

This tutorial demonstrates how to display a Java List of Strings in the Android UI. This example is also applicable if using an array of Strings.

Core Concepts Covered
  1. Use the built-in android.R.layout.simple_list_item_1 to create an Android UI List.
  2. Use android.widget.ArrayAdapter to display a List of Strings data in the Android UI List.
Summary Technical Steps
  1. Create class extending
  2. Obtain data in List of Strings data structure.
  3. Create an android.widget.ArrayAdapter that connects the List of Strings data to android.R.layout.simple_list_item_1.
  4. Bind the android.widget.ListAdapter using the ListActivity.setListAdapter method.
Detailed Technical Steps

1. Create class extending

public class MainActivity extends ListActivity {

    protected final void onCreate(final Bundle savedInstanceState) {
    2. Obtain data in List of String data structure.
    For this tutorial, we will use a List of Strings containing the 13 US original colonies. View the full code listing.

    public final class UsState {
        public static final List<String> ORIGINAL_COLONIES = initColonies();

        private UsState() { }

        private static List<String> initColonies() {
            final List<String> colonies = new ArrayList<String>();
            colonies.add("New Jersey");

            return Collections.unmodifiableList(colonies);
    3. Create an android.widget.ArrayAdapter in the ListActivity class from step 1 that connects the List of Strings data to android.R.layout.simple_list_item_1.

        private ListAdapter createListAdapter(final List<String> list) {
            return new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);

    4. Bind the android.widget.ListAdapter using the ListActivity.setListAdapter method.

    public class MainActivity extends ListActivity {

        protected final void onCreate(final Bundle savedInstanceState) {
            final ListAdapter listAdapter = createListAdapter(UsState.ORIGINAL_COLONIES);

    View the full code listing.

    The final result will look like this


    Source Code: Git | SVN | Download Zip


    1. Great Article. Thank you for sharing! Really an awesome post for every one.

      IEEE Final Year projects Project Centers in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Project Domains for IT It gives you tips and rules that is progressively critical to consider while choosing any final year project point.

      JavaScript Training in Chennai

      JavaScript Training in Chennai

    2. Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with extra information? It is extremely helpful for me. Download prince of persia iso ppsspp