Skip to content Skip to sidebar Skip to footer

Mono For Android: Spinner Within A Listview

I have a listview which is populated from a webservice using an ArrayAdapter. The webservice provides me with all the data I need. Some are just plain textviews yet other alternate

Solution 1:

Why do you think that it is not possible to instantiate an Adapter somewhere inside your custom Adapter for your ListView to populate content inside of it? You can simply make the implementation of the Adapter for your Spinner outside of the Adapter for the ListView.

Then you just need to think out a decoupled way to pass data through the hierarchy of Adapters so that all levels get the data you want.

However I don't think the ListView design pattern is suited for this kind of interaction and you will probably have problems with touch events not being fired. I think an ExpandableListView would be a more sensible choice of design pattern for what you are trying to achieve, and will have a better usability.

You can find an example of an ExpandableListView here: ExpandableListView Mono for Android

Solution 2:

Resolved using:

List<string> entries = newList<string>();

StringrawXML= item.OptBox_Options;

StringReaderstream=null;
XmlTextReaderreader=null;

DataSetxmlDS=newDataSet();
stream = newStringReader(rawXML);
// Load the XmlTextReader from the stream
reader = newXmlTextReader(stream);
xmlDS.ReadXml(reader);

DataSetmyOPTvalues=newDataSet();
myOPTvalues = xmlDS;

foreach (DataRow row in myOPTvalues.Tables[0].Rows)
{
    varoptItem=newPrevzemSpin();
    optItem.FieldValue = row["FieldValue"].ToString();
    if (optItem.FieldValue.Equals("")) optItem.FieldValue = null;

    optItem.FieldTextValue = row["FieldTextValue"].ToString();
    if (optItem.FieldTextValue.Equals("")) optItem.FieldTextValue = null;

    entries.Add(optItem.FieldTextValue);
    SpinnerValue.Tag = optItem.FieldValue;
}

Post a Comment for "Mono For Android: Spinner Within A Listview"