Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

EditText content in scroll ListView

$
0
0

Hi. I have LIstView with EditText in each row. User enters some data, but when he scroll down, and scroll up, the value is losing. Is there any way to save and restore entered data? When I scroll down, and up again xamarin invokes again default value for this ediText,, andI dont know how to save and restore data.

My adapter:

    public class Adapter : BaseAdapter<Product>
        {
           private List<Product> MyItems;
           private Context MyContext;
           public Adapter(Context context, List<Product> items)
           {
               MyContext = context;
               MyItems = items;

           }
            public override Product this[int position]
            {
                get { return MyItems[position]; }
            }

            public override int Count
            {
                get { return MyItems.Count; }
            }

            public override long GetItemId(int position)
            {
                return position;
            }

            public override View GetView(int position, View convertView, ViewGroup parent)
            {
                View row = convertView;


                if (row == null)
                {
                    row = LayoutInflater.From(MyContext).Inflate(Resource.Layout.productRow, parent, false);

                }
                TextView id = row.FindViewById<TextView>(Resource.Id.productOrderId);
                id.Text = ""+MyItems[position].id;

                TextView name = row.FindViewById<TextView>(Resource.Id.productOrderName);
                name.Text = MyItems[position].name;

                TextView stock = row.FindViewById<TextView>(Resource.Id.productOrderStock);
                stock.Text = ""+MyItems[position].quantity;

                TextView unit = row.FindViewById<TextView>(Resource.Id.productOrderUnit);
                unit.Text = "" + MyItems[position].unit;

                TextView price = row.FindViewById<TextView>(Resource.Id.productOrderPriceNet);
                price.Text = ""+MyItems[position].price;

                EditText numberPicker = row.FindViewById<EditText>(Resource.Id.productOrderQuantity);
                numberPicker.Text = "0";

                return row;
            }
        }

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>