[mono-android] problem with a Javalist (ArrayAdapter)

John Murray john at murray.gb.com
Thu Jan 5 09:36:28 EST 2012


I am trying to extract the content from a list view adapter  in order to
construct an sql statement 

 

The listview  is a specially subclassed multiline listview which takes a two
dimensional array to fill the lines 

Thus line one in the list view might be an array such s this  

 

{'recno','Keyno','date','name','address','etc' }

 

The array is a list of list  thus List<List<string>>()

 

So I come to the click handler and want to extract the 'Keyno' from the
array of the line selected 

 

I've got this code 

   private void loglist_ItemClick(object sender, ItemEventArgs e)

        {

            int pos = Convert.ToInt32(e.Id);

            var selitem = loglist.Adapter.GetItem(pos);

            var selitem2 = selitem.ToArray<string>();

            string sel2 = selitem2.ElementAt(0).ToString();

 

Sorry about the various selitems I've been trying everything - the debugger
tells me that the selitem is a JavaList - I can actually see the string I
want in the debugger by entering selitem.Get(1) - gives me {138} and
ToString() gives 138 as it should 

Trouble is I can't put this code into VS2010 - wont have it - i sees
'selitem' as a Hava.land.Object and the only methods available are
GetHashCode or GetType

The same applies if I use

selitem = loglist.GetItemAtPosition(pos)

 

I tried converting the 'selitem' ToArray<string>()  

This is accepted by the compiler but throws a null reference when run 

 

In  debugger I can use an indexer to get at the value I want  viz
"selitem[1]"

But when writing the code the compiler will not allow this 

Ditto the Java method get   - interestingly in the debugger I can write 

 

"selitem.Get(1) " 

 

And it delivers the correct value - I say interestingly because the java get
starts with a lowercase and all monodroid interpretations start with an
uppercase so I presume this is available in mono somehow

 

I am surely going round in circles and missing something obvious 

 

Help anyone pls ?

 

 

John Murray 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monodroid/attachments/20120105/6a88c536/attachment.html 


More information about the Monodroid mailing list