Hello,
i can't tell it can be 1 or 5 or10
Based on your needs, you do not need to reuse items and return the view directly, I removed reuse convertview code like following code.
The goal is to insert in database data (name birthdate ...) about persons and then displays in gridview and for each row a button and click will show data of the person if i have to update
If you need to insert items in the Gridview, you can invoke adapter.NotifyDataSetChanged();
method after inserting data to the List<Classdatabirth>
.
If you need to update items in the Gridview when you click item, I write a simple code to update item in the following code.
public override View GetView(int position, View convertView, ViewGroup parent)
{
var item = listbirthdate[position];
View view = convertView;
LayoutInflater inflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);
view = inflater.Inflate(Resource.Layout.tablebirthdate, null);
//if (view == null) // otherwise create a new one
//{
// // Create a new ViewHolder object
// LayoutInflater inflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);
// view = inflater.Inflate(Resource.Layout.tablebirthdate, null);
//}
//else
//{
// view = convertView;
//}
view.FindViewById<TextView>(Resource.Id.tablenamebirth).Text = item.namebirth;
view.FindViewById<TextView>(Resource.Id.tablesurname).Text = item.surname;
view.FindViewById<TextView>(Resource.Id.tabledatebirth).Text = item.datebirth;
view.FindViewById<TextView>(Resource.Id.tableremain).Text = item.remain;
Button button1 = view.FindViewById<Button>(Resource.Id.button1);
button1.Click += (o, e) =>
{
//if I need to change the namebirth when I click the button, set it and invoke NotifyDataSetChanged(); method
listbirthdate[position].namebirth="1233333444421";
NotifyDataSetChanged();
};
return view;
}
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.