Resource.Id 在 Xamarin 中不起作用 [英] Resource.Id not working in Xamarin
本文介绍了Resource.Id 在 Xamarin 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是 main.axml 文件.
This is main.axml file.
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myListView" />
</LinearLayout>`
这是 MainActivity.cs 文件:
And this is the MainActivity.cs file :
protected override void OnCreate(Bundle bundle){base.OnCreate(bundle);
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
Glop = new List<string>();
Glop.Add("Tom");
Glop.Add("Dick");
Glop.Add("Harry");
Name = FindViewById<ListView>(Resource.Id.myListView);
}
我正在尝试在 Xamarin Android 中创建一个列表视图.
I am trying to create a Listview in Xamarin Android.
我已将 android Id 更改为 myListView 并尝试重建应用程序,但它仍然显示为错误.我现在该怎么办?
I have changed the android Id to myListView and also have tried to rebuild the app but it still shows as an error . What should I do now ?
推荐答案
再次尝试重建应用程序并保存 main.axml 文件.
Try rebuilding the app again and saving the main.axml file .
构建 > 清洁解决方案
Build > Clean Solution
构建解决方案
这篇关于Resource.Id 在 Xamarin 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文