Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monodroid Spinner Resource reference error

I'm following the spinner from monodroid tutorial. But encountered problem on the resource.enter image description here

It cannot lookup the SimpleSpinnerItem & SimpleSpinnerDropDownItem on VS 2010. Am I missing something?

Edit: Create a partial class to register android runtime as per jonp

public partial class Resource
{
    public partial class Layout
    {
        [Register("simple_spinner_dropdown_item")]
        public const int SimpleSpinnerDropDownItem = 17367049;
        [Register("simple_spinner_item")]
        public const int SimpleSpinnerItem = 17367048;
    }
}

Edit 2: Tried the global resource

enter image description here

Edit 3: Conflict on my project namespace

I already identified why the const cannot be recognize. It's because of my namespace projectname.Android, it's being duplicated. When I changed it to projectname.AndroidMobile the global resource is there.

See the conflict below.

enter image description here

Also, to avoid the conflict just use the global:: as per jonp

like image 351
Petrick Lim Avatar asked Mar 22 '26 15:03

Petrick Lim


1 Answers

You need to qualify the class, as there are two Resource types: one local to your project (Your.Namespace.Resource, located in Resource.designer.cs), and global::Android.Resource. You need to use global::Android.Resource.Layout.SimpleSpinnerItem.

like image 114
jonp Avatar answered Mar 24 '26 22:03

jonp