DEFALT
DEFALT

Reputation: 149

Resource does not contain a Definition for Id - c# Xamarin Visual Studio

I am trying to get an Array from the Strings.xml via the below command:

        string[] menuItems = Resources.GetStringArray(Resource.Array.menu);

But I am getting the following error:

       'Resource' does not contain a definition for 'Array'

Also I am getting the same type of error for the following line:

    TextView webAddress = view.FindViewById<TextView>(Resource.Id.txtTourUrl);

'Resource' does not contain a definition for 'Id'

I am guessing it has something to do with the Resource.Designer.cs file, but I am not sure how to fix it...

UPDATE 1:

These are the Options to fix it:

enter image description here

Thanks in advance.

Upvotes: 1

Views: 1248

Answers (1)

DEFALT
DEFALT

Reputation: 149

For those of you who may have the same problem...

The reason it was not Rebuilding is because there was an error in my Main.axml file where an object / widget id was: android:id="@android:id/ list" Notice the Space before the ID name...

This causes an error with rebuilding and was unable to generate a class for the Resource.Id in Resources.

Just remove any Spaces or any Symbols that may cause the error and Rebuild Solution again.

Upvotes: 1

Related Questions