我在自定义列表视图中按字母顺序排列了客户列表,但我意识到我正在获取列表视图控件的位置,但不是对象。例如,我有这个代码:
//Here i am delegating
_list.ItemClick += ListView_ItemClick;
//On this one i am ordering the list of customer alphabetically
customers = customers.OrderBy(c => c.CustomerName).ToList();
private void ListView_ItemClick(object sender, ItemEventArgs e)
{
//Toast.MakeText(this, ((TextView)(view)).Text, ToastLength.Short);
Customer cust = Customer.GetCustomer(e.Position + 1);
var intent = new Intent();
intent.SetClass(this, typeof(CustomerDetails));
intent.PutExtra("custNumber", cust.CustomerNumber);
intent.PutExtra("nameCustomer", cust.CustomerName);
intent.PutExtra("customerAdress", cust.Adress);
intent.PutExtra("customerCreditLimit", cust.CreditLimit);
intent.PutExtra("contactName", cust.ContactInformation.ContactName);
intent.PutExtra("contactPhoneNumber", cust.ContactInformation.TelephoneNumber);
intent.PutExtra("contactMail", cust.ContactInformation.Mail);
intent.AddFlags(ActivityFlags.NewTask);
StartActivity(intent);
}
所以我想知道如何让对象找到我想在下一页显示的特定客户。
答案 0 :(得分:1)
如果没有看到你正在做的其他事情,很难肯定地说,但看起来你可以利用这个职位将客户排除在列表之外:
var customer = customers[e.Position];