1

I have a Xamarin.Forms solution in which inside my Android project I have a custom BroadcastReceiver. Inside this class I'm trying to create a custom notification layout using RemoteViews which was explained to me using this thread.

However I am having problems with the construction of this class using the RemoteViews(Android.Content.Context,Resource.Layout) constructor. Specifically the Resource.Layout portion. When I go into the 'Resources' folder there is only a Drawable folder (even when 'Show All Files' is enabled). Which is interesting considering I can access layouts after typing Resource.Layouts.

Resource Folder

Is there a way to get a custom .xml id int (or .axml if that's the case) to be referenced for this strategy inside the Layout 'folder', or any other way Xamarin does instead that I may not have knowledge of?

B Best
  • 1,106
  • 1
  • 8
  • 26
  • In Xamarin.Android, we usually use `.axml` as a layout file. Are you using Visual Studio? Could you please post a screenshot of your Resource folder? – York Shen Jul 14 '17 at 03:06
  • Are you using Visual Studio 2015? Could you please post your `Resource.Designer.cs` code? – York Shen Jul 14 '17 at 05:54
  • Any specific part cause it is extremely long? @YorkShen – B Best Jul 14 '17 at 11:45
  • When you write a `xx.axml` file, it will register a resource Id in your `Resource.Designer.cs`, so that you could find the `xx.axml` when you use `Resource.Layout`. This work usually did by visual studio, if not, you cant find it as your question. – York Shen Jul 14 '17 at 14:16
  • Anytime I make an `.axml` or `.xml` file anywhere inside the Android project of my Xamarin.Forms solution it brings up the same error and breaks the build. – B Best Jul 14 '17 at 22:09
  • Are you using Visual Studio 2015? – York Shen Jul 15 '17 at 04:52
  • Yes, I have VS 2017 too but I've been using 2015 – B Best Jul 15 '17 at 14:54
  • This usually happens in vs 2015, you could use vs 2017 and try again. – York Shen Jul 15 '17 at 15:33

1 Answers1

0

Essentially all you have to do is add a folder in the Android project named "Layout" under the Resources folder. Then create the .axml file. Then the file can be referenced using Resources.Layout and the id retrieved using the method from this thread.

B Best
  • 1,106
  • 1
  • 8
  • 26