tags:

views:

55

answers:

2

I can't fill a ListView layout with an array of strings. Here is the Activity:

 ListView symptomList = (ListView) findViewById(R.id.ListView_Symptom);
 String symptomsArray[] = new String[1024];
 // Then I fill up symptomsArray
 ArrayAdapter<String> adapt = new ArrayAdapter<String>(this, R.layout.menu_item, symptomsArray);
    symptomList.setAdapter(adapt);

Here is menu_item:

<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:textSize="@dimen/menu_item_size"
android:text="test string"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"
android:shadowRadius="5"
android:gravity="center"
android:shadowDy="3"
android:shadowDx="3" />

And here is symptom.xml -

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
        android:layout_height="wrap_content"
        android:id="@+id/ListView_Symptom"
        android:layout_width="fill_parent"
        android:divider="@drawable/divider"
        android:listSelector="@drawable/textured"
        android:layout_alignParentTop="true"></ListView>

 </LinearLayout>

Does anyone have any idea what is wrong? Does my public class need to extend "ListActivity". I tried that and that didn't work.

A: 

Try stripping out some of the presentational bits from your TextView. For example, I don't think that you want android:layout_gravity="center" there. Also, try setting your ListView's android:layout_height="fill_parent".

Steve Pomeroy
I tried removing the items you suggested, and I still see a black screen. This black screen is shown after clicking a button on the splash screen to select this activity which should fill a ListView with an array of strings.
James Testa
A: 

Turns out Eclipse is so slow running on my 5 GB Dram MacPro that it eventually worked and displayed the array in the ListView, it just took a few minutes! Sorry about the confusion.

James Testa