Everything you need to know is shown in the various samples called List1.java through List14.java in the ApiDemos sample apps in the SDK :)
On Wed, May 5, 2010 at 7:28 AM, jul <[email protected]> wrote: > Hi, > > I'd like to display a list in a layout. As shown below in my code, I > create a class that extends ListActivity and set the content view to > my main layout, but I can't find out how to display the string array. > Anybody can help? > > Thanks > Jul > > > ********** Atable.java ********** > > package org.digitalfarm.atable; > > import android.app.ListActivity; > import android.os.Bundle; > > public class Atable extends ListActivity { > > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > String[] COUNTRIES = new String[] { "Afghanistan", > "Albania", "Algeria", "American Samoa", "Andorra"}; > > //How do I display the string array in the ListView in my > main.xml? > } > } > > ********** main.xml ********** > > <?xml version="1.0" encoding="utf-8"?> > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ > android" > android:orientation="vertical" > android:layout_width="fill_parent" > android:layout_height="fill_parent" > > > > <LinearLayout android:orientation="horizontal" > android:layout_width="fill_parent" > android:layout_height="wrap_content"> > <TextView android:layout_width="wrap_content" > android:layout_height="wrap_content" > android:text="@string/search" /> > <EditText android:id="@+id/search" > android:layout_width="wrap_content" > android:layout_height="wrap_content" > android:layout_weight="1"/> > </LinearLayout> > > <LinearLayout android:orientation="vertical" > android:layout_width="wrap_content" > android:layout_height="wrap_content"> > > <ListView android:id="@id/android:list" > android:layout_width="wrap_content" > android:layout_height="wrap_content"/> > <TextView android:id="@id/android:empty" > android:layout_width="wrap_content" > android:layout_height="wrap_content" > android:text="@string/noresults"/> > </LinearLayout> > > </LinearLayout> > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Romain Guy Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

