listView, ArrayAdapter SimpleListItem1Help

BlueScreenThisBlueScreenThis ✭✭USMember ✭✭

Hello,
I'm trying to use pull data from MySQL to a list view but the code I have built is only displaying the very last entry within MySQL.

if I have 25 rows in the MySQL database and I want to display data from the rows that have 'soothe' within the rows, the code will only display row 25.
row 2, 8, 13, and 25 have the word 'soothe' within them. I want to display all 4 of those rows but my listview only displays one Item within the listview.

The code I have been working with.

                       MySqlDataReader mdr;
                            command = new MySqlCommand(selectFromDB, con);
                            con.Open();
                            mdr = command.ExecuteReader();
                            //mdr.Read();


                       while(mdr.Read())
                        {
                            mItems = new List<string>();
                            mItems.Add(mdr.GetString("soothe"));

                            ArrayAdapter<string> adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, mItems);

                            mlistview.Adapter = adapter;                       
                        }

I think this has something to do with the UI not updating. I have looked around the internet but I'm stuck. can someone please point me in the correct direction?

Best Answer

Answers

  • BlueScreenThisBlueScreenThis ✭✭ USMember ✭✭

    this is a duplicate of https://forums.xamarin.com/discussion/94368/listview-and-arrayadapter#latest

    when I posted this, Xamarin forums had removed it for some reason. I see its back.....

Sign In or Register to comment.