goldsmit409
goldsmit409

Reputation: 478

Confused with namespaces in android xamarin

i have run into a problem with namespace i have a name space as MyApp.Android and MyApp.Windows, now in a Activity class i am trying to define the attributes for the activity as below

   [Activity(ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.ScreenSize)]

but here Android is resolved as MyApp.Android and not just android, it is not possible for me to change the namespace for the whole app any other way around this.

sorry for noobness

Upvotes: 0

Views: 404

Answers (1)

patridge
patridge

Reputation: 26565

There are a couple approaches you can try to handle these Android naming collisions (in addition to prefixing it with global:: as you already found). Some will serve you better than others depending on the exact circumstances of the name collision.

You could eliminate the long qualification and put a using statement to get you down to that point in the hierarchy.

using Android.Content.PM;

...

[Activity(ConfigurationChanges=ConfigChanges.Orientation | ConfigChanges.ScreenSize)]

As well, in some different situations with this issue, you may want to create a "using alias" for any types you are using. You would still shorten the final calls to ConfigChanges.{whatever}.

using ConfigChanges = Android.Content.PM.ConfigChanges;

...

[Activity(ConfigurationChanges=ConfigChanges.Orientation | ConfigChanges.ScreenSize)]

This later approach probably doesn't help in your situation, but can come in handy when you start using the Android Support Libraries (e.g., using FragmentManager = Android.Support.V4.App.FragmentManager; when you may already have a using Android.App; which has the non-support FragmentManager).

Upvotes: 2

Related Questions