xamarin.android - 导航到其他视图时如何解决活动未找到异常?
问题描述
我得到一个 Android.Content.ActivityNotFoundException: 当我想去另一个活动时。此外,每次我想查看我的应用程序时,我都必须重新创建我的模拟器,因为它在我第二次启动模拟器时总是会导致 adb 错误。
我读到这可能是由另一个异常引起的,但是我检查了另一个代码,但没有找到任何东西
Button btnentrar = FindViewById<Button>(Resource.Id.createlist);
btnentrar.Click += delegate
{
StartActivity(typeof(listeditorclass));
};
//活动:
private List<string> mItems;
private ListView mListView;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.listeditor);
mListView = FindViewById<ListView>(Resource.Id.listView);
mItems = new List<string>();
mItems.Add("Milch");
mItems.Add("Brot");
mItems.Add("Apfel");
MyListViewAdapter adapter = new MyListViewAdapter(this, mItems);
mListView.Adapter = adapter;}
我也不知道 AppCompatActivity 和正常活动之间的区别。所以一般用户在单击按钮时应该会看到带有我的列表的新视图(创建列表)。
解决方案
我以前没有在 Xamarin 上使用过匿名代表,这是一件很酷的事情。尝试使用意图并传递Context
:
btnentrar.Click += delegate
{
StartActivity(new Intent(this, typeof(listeditorclass)));
};
推荐阅读
- node.js - 如何使用 discord.js 执行“报告错误”命令
- unit-testing - 普罗米修斯:“for”打破了我的考验
- sql - 我收到此错误“无法绑定多部分标识符“DCOT.Loyalty”。”
- google-cloud-platform - GCP 默认服务帐户和自定义服务帐户有什么显着区别?
- python - 键入 Python tkinter 条目时的数字分组
- variables - Nginx 1.21.0 如何在 ssl_certificate 中使用变量?
- css - CSS 网格项目放置
- reactjs - 无法访问 react-bootstrap-table-next 中的嵌套数组
- vba - 将列从一个工作簿复制并粘贴到另一个插件
- r - 五个尺度和四个类别的堆叠条