我在Xamarin Android中使用ListView来显示餐厅列表,当单击一个餐厅时,我想导航到一个新活动。每个活动均使用以下约定命名:[restaurantName]活动。我正在尝试使用意图:
protected override void OnListItemClick(ListView l, View v, int position, long id)
{
string t = items[position] + "Activity";
var intentPlace = new Intent(this, typeof(???));
StartActivity(intentPlace);
}
字符串t给出正确的格式,但是放在typeof()中的类型错误。但是,我不知道该用什么代替'???',因为我无法使用setTitle来创建活动名称。有人能指出我正确的方向吗?
您需要为活动添加完整路径。
var actType = Type.GetType("part of full path" + items[position] + "Activity")
我还没有测试过,但是它应该可以工作了:)
protected override void OnListItemClick(ListView l, View v, int position, long id)
{
var actType = Type.GetType("part of full path" + items[position] + "Activity")
var intentPlace = new Intent(this, actType);
StartActivity(intentPlace);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句