Thought this might be interesting for others.  Here is a bare bones
simple  ListView widget in a base Activity - NOT a ListActivity.
There is no explicit Adapter - it uses the "android:entries" attribute
to load the list data from a resource.  Probably not something you
would use in a real app, but maybe instructive for understanding the
ListViews.

--- MyListActivity.java ---
package foo.listview;

import android.app.Activity;
import android.os.Bundle;

public class MyListActivity extends Activity
{
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mylistview);
    }
}

--- res/layout/mylistview.xml ---
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
        <ListView
           android:layout_width="fill_parent"
           android:layout_height="fill_parent"
           android:entries="@array/mylistviewdata"/>
</RelativeLayout>

--- res/values/mylistdata.xml ---
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="mylistviewdata">
        <item>"1952 Albert Schweitzer"</item>
        <item>"1954 UN Office for Refugees"</item>
        <item>"1962 Linus Pauling"</item>
        <item>"1964 Martin Luther King"</item>
        <item>"1975 Andrei Sakharov"</item>
        <item>"1978 Anwar Sadat &amp; Menachem Begin"</item>
        <item>"1977 Amnesty International"</item>
        <item>"1979 Mother Teresa"</item>
    </string-array>
</resources>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to