android - When I add a new item in Listview previous values are deleted -
When I add a new item to my ListView, it is losing the values present. This was added only to the new value that was added. The goal is to add a new value without losing the existing ones. My code:
list & lt; String & gt; List = new list & lt; String & gt; (); Zero btnAddItem_Click (object sender, EventArgs e) {ArrayAdapter & lt; String & gt; Adapter; String edttxNewItem = FindViewById & lt; Editingtext & gt; (Resource.ind.nuitim). Text; ListView ListItm = SearchWebID & lt; ListView & gt; (Resource.ind.listoff items); List.Add (edttxNewItem); Adapter = New Arrayheader & lt; String & gt; (This, Android. Resource Layout. Simplelist ITM1, list); ListItems.Adapter = Adapter; ListItems.DeferNotifyDataSetChanged (); }
I am unfamiliar with xamarin
, but It looks like you are trying to create a listview example on btnAddItem_Click
then start listItems
in the form of oncreate
method
listItems = FindViewById & lt; ListView & gt; (Resource.ind.listoff items); Define as
and listItems
class variables.
and adapter
are called in the btnAddItem_Click
, OnCreate
method.
adapter = new array adapter & lt; String & gt; (This Android. Resource Layout, Simple List ITM1, List); Add listItems
to in btnAddItem_Click
just edttxNewItem
and notifydatasetchanged
Code> xamarin
in
Comments
Post a Comment