tags:

views:

38

answers:

1

Is there anything bad with this code?

The thing is that the "test" is not displayed in ListView.

Java:

private ListView namesListView;
private ArrayList<String> names;
private ArrayAdapter<String> namesAA;
...
namesListView = (ListView)findViewById(R.id.list);
names = new ArrayList<String>();
names.clear();
names.add(0, "test");
namesAA = new ArrayAdapter<String> ( this, android.R.layout.simple_list_item_1, names );
namesListView.setAdapter(namesAA);
...

XML:

<ListView 
    android:id="@+id/list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
/>
A: 

The first thing I pick up is that layout_height is set to wrap_content which will not allocate more height than it absolutely needs. This is sort of paradoxal for a scrolling view, because there's really no physical limit to how small it could be.

I'm guessing that's where your problem is.

David Hedlund
Hi,I tried to change it to "fill_parent" it has not effect.STeN
STeN