Hello,
Welcome to our Microsoft Q&A platform!
I have it so that it will return the lastly created table and its info, but I instead need it to return the table info from whichever table was just pressed
@KLubin For this function, try detecting the ItemClick event of the listView to get the current position. Then get the item data using the position to retrive info from the table. I write a basic demo about the function, you could refer to the code:
ListView listview_ = FindViewById<ListView>(Resource.Id._listview);
List<CustomModel> dataList = new List<CustomModel>();
//get data from the database
CustomAdapter adapter = new CustomAdapter(dataList);
listview_.SetAdapter(adapter);
listview_.ItemClick += (o, s) =>
{
string name = list[s.Position].Name;
//query the data from the table with the name
};
CustomAdapter class
public class CustomAdapter : BaseAdapter<CustomModel>
{
List<CustomModel> list_ = new List<CustomModel>();
public _Adapter(List<CustomModel> list_)
{
this.list_ = list_;
}
...
public override View GetView(int position, View convertView, ViewGroup parent)
{
var view = convertView;
view = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.layout1, parent, false);
var textview = view.FindViewById<TextView>(Resource.Id.text_);
textview.Text = list_[position].Name;
return view;
}
}
CustomModel class
public class CustomModel
{
...
public string Name { get; set; }
}
Best Regards,
Jarvan Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
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.