[mono-android] creating adapter from resource

John Murray john at murray.gb.com
Sun Mar 27 09:28:12 EDT 2011


I am trying to find the most efficient way of loading list info 

In past on win forms I've used xml files 

In Monodroid seems fastest to me to have a resource list_array and create an
adapter from that 

So can anyone tell me why the first of these doesn't work but the second
does 

(what I mean is I'm creating an adapter to service an autocomplete text box
and the create from resource does not chow any auto complete prompt so I
presume it is not loading - yet the ther approach does work)

 

Simple approach which doesn't work 

airfadapter =new ArrayAdapter(this, Resource.Layout.list_item,
Resource.Array.GBairfarr1);

              depfield.Adapter = airfadapter;

            

I've even tried adding this 

adapter.CreateFromResource(this,Resource.Array.GBairfarr1,Resource.Layout.li
st_item);

 

 

But this works 

Android.Widget.ArrayAdapter<string> adapter = new
ArrayAdapter<string>(this,Resource.Id.wtv2);            

            List<string> arr3 = new List<string>();

            arr3 = (from s in
Resources.GetStringArray(Resource.Array.airfarr1) select s).ToList();

            foreach (var s in arr3)

             {

                 if (s.Substring(0,2)=="EG")

                 {

                adapter.Add(s);

                 }

             }

depfield.Adapter = adapter;

 

//the above foreach loop was only inserted t filter the list and has no
significance in this 

//other than it serves as a means for getting a list into an android adapter


         

 

Ps is there some easy way to convert a System.collection.list to an
android.widget.arrayadapter

 

John Murray

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110327/449d6003/attachment-0001.html 


More information about the Monodroid mailing list