Dany BREARD wrote:
> Hi everybody
>
> I just to make a simple list view and display it.
> I can't dispaly my list, maybe I forgot something.
>
> Java:
> package m.dany.android.testandroid;
>
> import android.app.Activity;
> import android.os.Bundle;
> import android.widget.ArrayAdapter;
> import android.widget.ListView;
>
> public class MyActivity extends Activity {
>
> ListView list;
>
> public void onCreate(Bundle savedInstanceState){
> super.onCreate(savedInstanceState);
> setContentView(R.layout.main);
>
> String[] mString = {"item1", "item2", "item3"};
>
> list = new ListView(this);
>
> ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
> R.id.item, mString);
>
> list.setAdapter(adapter);
> }
> }
>
> And
>
> 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">
>
> <TextView
> android:id="@+id/item"
> android:layout_width="wrap_content"
> android:layout_height="wrap_content"/>
>
> </LinearLayout>
Right now, you have not told Android to display your list anywhere. Try
adding setContentView(list); at the bottom of your onCreate().
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy
Android Development Wiki: http://wiki.andmob.org
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---