create an ArrayAdapter and add list items to it.

then use list.setAdapter(adapter);


On Thu, Mar 11, 2010 at 5:22 AM, Kitzy <[email protected]> wrote:

> Search for how to fill an ArrayAdapter with an xml file, there are
> also examples which come with the sdk examples. You should create an
> array file in your res/values directory and you will have to have all
> the contries you want lited in it.
>
> -Kitzy
>
> On Mar 7, 12:46 pm, plexus <[email protected]> wrote:
> > How can I populate array COUNTRIES to the ListView "list"   @+id/
> > lKompListe ?
> >
> > =========
> > 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:id="@+id/LinearLayout01"
> >                 android:layout_height="wrap_content"
> > android:layout_width="fill_parent">
> >                 <Button android:layout_width="wrap_content"
> >                         android:layout_height="wrap_content"
> android:id="@+id/
> > buttonTilbake"
> >                         android:text="Tilbake"></Button>
> >                 <TextView android:layout_width="wrap_content"
> >                         android:layout_height="wrap_content"
> android:id="@+id/textTittel"
> >                         android:layout_weight="1" android:textSize="18dp"
> > android:textStyle="bold"
> >                         android:layout_gravity="center"
> android:gravity="center"
> >                         android:text="Velg komponent"></TextView>
> >                 <Button android:id="@+id/Button01"
> > android:layout_width="wrap_content"
> >                         android:layout_height="wrap_content"
> android:text="Endre"
> >                         android:visibility="invisible"></Button>
> >         </LinearLayout>
> >         <ListView android:layout_width="wrap_content"
> >                 android:layout_height="wrap_content"
> android:layout_weight="1"
> >                 android:id="@+id/lKompListe"></ListView>
> > </LinearLayout>
> >
> > =========
> > JAVA
> > =========
> > public class VelgKomponent extends Activity {
> >         Button tilbake;
> >         Intent intent;
> >         ListView list;
> >
> >         static final String[] COUNTRIES = new String[] { "Afghanistan",
> > "Albania",
> >                         "Algeria", "American Samoa" };
> >
> >         @Override
> >         public void onCreate(Bundle savedInstanceState) {
> >                 super.onCreate(savedInstanceState);
> >                 setContentView(R.layout.velgkomp);
> >
> >                 tilbake = (Button) findViewById(R.id.buttonTilbake);
> >
> >                 View.OnClickListener handler = (new
> View.OnClickListener() {
> >
> >                         @Override
> >                         public void onClick(View v) {
> >                                 switch (v.getId()) {
> >                                 case R.id.buttonTilbake: // doStuff
> >                                         intent = new
> Intent(v.getContext(), ShoppingBasket.class);
> >                                         startActivity(intent);
> >                                         break;
> >                                 }
> >                         }
> >                 });
> >
> >
> findViewById(R.id.buttonTilbake).setOnClickListener(handler);
> >                 list = (ListView) findViewById(R.id.lKompListe);}
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Beginners" group.
>
> NEW! Try asking and tagging your question on Stack Overflow at
> http://stackoverflow.com/questions/tagged/android
>
> To unsubscribe from this group, send email to
> [email protected]<android-beginners%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-beginners?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to