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>`
And this is the MainActivity.cs file :
protected override void OnCreate(Bundle 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); }
I am trying to create a Listview in Xamarin Android.
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 ?
Try rebuilding the app again and saving the main.axml file .
Build > Clean Solution
For Visual Studio Community 2019 Preview (V 16.0.0, Pr 5.0):
For this problem and a lot of the problem with the designer I have to repeatedly do the following:
- Save all documents and close VS.
- Navigate to the project folder in your file browser
- Delete (or rename, if you’re paranoid) the “obj” and “bin” folders
- Relaunch VS and try the designer again.
With this version (granted, it’s still beta) running a clean on the project with the designer open will cause access permission errors that can be corrected with these steps.
1)Build -> Clean Solution
Option 1) Make sure update the Xamarin.Android (Tools>Options>Xamarin>Other>Check Now)
Option 2) Run VS as Administrator and Build>Clean and Rebuild the solution.
I faced this kind of problem. The cause may be from the duplicate resource IDs in the project. For instance, this problem occurs when you copy a layout file (.axml) and simply paste directly into the layout resource folder in the solution explorer pane without meticulous resource ID name review in it.
Since the ID reference rule in the project’s namespace is to be unique. While the resource ID is auto-generating in the .Designer file, The VS couldn’t determine which one is the right one you intend to use, so all cases of the same resource IDs may be skipped and unprocessed without warning.
The result is – after I made a duplicate layout file in the same project, later I couldn’t reference resource name or ID of them while I’m coding.
The solution for me is to look for the duplicate IDs name in the project and correct them to be unique.