Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Problem with Listview only showing the first item

$
0
0

Hello,

I have a problem with a listview on my activity which is only showing the first item from the list.

I have a custom adapter which inflates an Axml file to display the list items

this layout looks like this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:paddingLeft="5dip"
    android:paddingRight="5dip"
    android:paddingTop="8dip"
    android:paddingBottom="8dip">
    <LinearLayout
        android:orientation="vertical"
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:id="@+id/linearLayout1">
        <TextView
            android:text="Medium Text"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/functionName" />
        <TextView
            android:text="Small Text"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/functionStrategy" />
    </LinearLayout>
    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/isActive"
        android:layout_alignParentRight="true" />
</RelativeLayout>

the adapter I use is pretty straight forward looking like this:

class OwnFunctionAdapter : BaseAdapter<Functions>
{
    List<Functions> data;
    Activity context;

    public OwnFunctionAdapter(Activity context, List<Functions> data)
        : base()
    {
        this.context = context;
        this.data = data;
    }

    public override Functions this[int position]
    {
        get { return data[position]; }
    }

    public override int Count
    {
        get { return data.Count; }
    }

    public override long GetItemId(int position)
    {
        return data[position].FunctionId;
    }

    public override View GetView(int position, View convertView, ViewGroup parent)
    {
        View view = convertView;
        if (view == null)
        {
            view = context.LayoutInflater.Inflate(Resource.Layout.FunctionListItem, null);
        }
        view.FindViewById<TextView>(Resource.Id.functionStrategy).Text = data[position].StrategyName;
        view.FindViewById<TextView>(Resource.Id.functionName).Text = data[position].Name;
        view.FindViewById<CheckBox>(Resource.Id.isActive).Checked = data[position].IsActive;
        return view;
    }
}

when this is used in the activity

    private List<Functions> ownfunctions;


    ownfunctions = backgroundServiceConnection.Binder.GetBackgroundService().GetFunctionsInfo();
    var list = (ListView)FindViewById(Resource.Id.functionlist);
    list.Adapter = new OwnFunctionAdapter(this, ownfunctions);

by debugging I know the Ownfunctions list contains valid data and contains three items.

in the output window I have the following message directly underneath the debug entries surrounding the code above:

W/TextLayoutCache(24286): computeValuesWithHarfbuzz -- need to force to single run

is there somebody who knows what is happening? I tried it in both the emulator and a real device, but I can't get it to shown all three items.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>