How to Implement a List in Android XML

The "List" view items in Android development displays several items from which your users can select. Android programmability is created in Java, but you use XML to lay out your list items. The Eclipse Android SDK has a designer you use to create list items, or you manually insert each item directly in the Android XML file.

Instructions

    • 1

      Double-click the "Eclipse.exe" file to open the Eclipse software. If you do not have a shortcut set up, click the Windows "Start" button and type "eclipse.exe" to find the software's executable.

    • 2

      Double-click the "res" directory in the left panel. This directory contains each menu and layout for your Android app. Double-click the XML file you want to use to create the list of items.

    • 3

      Add your list items. The following code is an example of a list of two items:

      <menu xmlns:android="http://schemas.android.com/apk/res/android">
      <item android:id="@+id/item1"
      android:icon="@drawable/help"
      android:title="@string/My Item1 Text" />
      <item android:id="@+id/item2"
      android:icon="@drawable/ic_help"
      android:title="@string/My Item1 Text" />
      </menu>

      The "ID" tag is required to interface between your users and the Android device. The "Title" tag displays the icon's text. This tag text is what your users see when the Android screen is displayed. You can continue to add items to the list, but each item must have its own unique "ID" in the list.

Related Searches:

References

Comments

Related Ads

Featured