Android的xamarin C#如何让TwoLineListItem列表视图中
问题描述:
我有一个关于我的xamarin Android项目问题
目前,我遇到了我的列表视图的一个问题,我有1列
并希望其下添加一些文本,例如一个描述
I have a question about my xamarin android project currently i ran into an issue with my listview i have 1 row and want to add some text under it for example an description
目前
理念
The Idea
结果
当前使用的code IM是:
the code im currently using is:
ListView listView;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
Bla WebS = new Bla ();
var ListSort = WebS.Fetch(Core.AdresID, DateTime.Today.Year, null);
var Sorts = ListSort.Where(i => i.Date >= DateTime.Today).Select(k=> k.Sort).ToArray();
var Dates = ListSort.Where(i => i.Date >= DateTime.Today).Select(k => k.Date).ToArray();
listView = FindViewById<ListView>(Resource.Id.ListView1);
listView.Adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItemSingleChoice, Sorts);
listView.ChoiceMode = ChoiceMode.Single;
listView.ItemClick += new EventHandler<AdapterView.ItemClickEventArgs>(listView_ItemClick);
}
void listView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
{
ListView listView = sender as ListView;
if (listView != null)
{
MessageBox("Chosen item: " + listView.Adapter.GetItem(e.Position));
}
}
是否有人知道如何到达呢?
Does someone know how to reach that ?
答
您应该继承 ArrayAdapter
(或我使用的主要是 BaseAdapter
),然后你可以设置为每行自定义布局。
You should subclass ArrayAdapter
(or I use mainly BaseAdapter
), and then you can setup a custom layout for each row.
下面是Xamarin的商务部网站,进入自定义行布局的一部分。
Here is an example on Xamarin's doc website, go to the custom row layout part.