I want to add items to it from a foreach loop. My problem is that I can only see one item no matter how many I add. I've made an example code below with my problem in it. Starting with my layout.
<?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"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:focusableInTouchMode="true">
<ScrollView android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:focusableInTouchMode="true">
<TextView
android:textSize="10pt"
android:id="@+id/HeaderLbl"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:textSize="7pt"
android:id="@+id/ErrorLbl"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#ffff0000"
/>
<Spinner
android:id="@+id/OrderSpinner"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
>
</Spinner>
<TextView
android:textSize="8pt"
android:id="@+id/OrderRef"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:textSize="7pt"
android:id="@+id/OrderDateTime"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:textSize="7pt"
android:id="@+id/OrderCustomer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:textSize="7pt"
android:id="@+id/OrderInnerComment"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Spinner
android:id="@+id/ArticleSpinner"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
>
</Spinner>
<ListView
android:id="@+id/OperationsListView"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
>
</ListView>
</LinearLayout>
</ScrollView>
</LinearLayout>
And here I simulate my foreach loop adding items to it.
ArrayAdapter CalculationAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1);
ListView OperationsListView = FindViewById<ListView>(Resource.Id.OperationsListView);
for (int i = 0; i < 3; i++)
{
CalculationAdapter.Add(i.ToString());
}
OperationsListView.Adapter = CalculationAdapter;
Help is most appreciated! Thank you.
EDIT: I think the scrollview was the problem.
<ScrollView android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
I removed it and then it worked :) Don't understand why tho.. How can I put a ListView into a ScrollView without it collapsing? Mabye this can help any others with same prob