NativeCSS & Xamarin.Android - c#

I need some help getting NativeCSS running for Xamarin.Android (in Xamarin Studio).
What I have done:
-Added .dll to References in my Xamarin project.
-Added styles.css file to different folders (root, Assets, Resources, and also to the debug output folder). (Question: What is the folder, NativeCSS expects the .css file??)
-Added the following code to my MainActivity.cs:
NativeCSS.StyleWithCSS("styles.css",
new Uri("http:url"),
RemoteContentRefreshPeriod.Never);
But I can not see any style changes of my project.
I hope somebody can help me.
I really appreciate every help.

Checkout the sample project TaskyDroid, which does exactly what you want:

Related

Visual Studio and Project don't see new classes/folders etc after adding new classes and folders for the project cloned from GIT

I cloned my project from the github repository.Now i made a new folder in this project and added here a class with a namespace.However, when i tried to add a using command with this namespace(c#) to another class(this class was in my project from the start, because it was in git repo), I noticed that project doesn't see this Folder/Class/Namespace.I don't really know what can I do so I'll be very grateful if you will help me(VS 2019)
Try to open the project file (unload the project and edit proj file)
Check if the Folder is in there.
If not, you can manually insert it and reload the project.
Oh and in case that you reference to another project, check if the newer projects framework version is not over the referencing project.
This could also be a possible error.
I know it's quite old topic, but I've got the same issue today. And the reason was that I created repo with a name containing space, like "My repo".
In the link generated by git, repo name was "My%20repo". And the same directory was created on my local machine (os: win 10).
It appears that VS can't treat "My%20repo" as valid directory name, and no directory nor file has been added to project on creation. Strange thing is, any file or directory created later has been perfectly visible.
So I've just changed directory name to get rid of this "%20" part, now it works just as supposed.
Not sure if that's true reason. But that's my experience I wanted to share :)
Follow this link, may be it could help:
visual-studio-2019-doesnt-include-on-csproj-new-files
This solve the issue: update the package Microsoft.Net.Compiler to the latest version, compile and try adding a new class to your project again.

Xamarin new project error

I just started learning Xamarin and I am having some problems. I created a new Android App Project, using a Single View App. I just open the activity_main.axml using the solution explorer and after it loads, i get the following error: "This project contains resources that were not compiled successfully, rendering might be affected." Even if I try to rebuild the solution, the error persists.
Worth mentioning: this happens without editing/writing any code and without adding any objects through the toolbox.
Any ideas? Thanks!
Try to go on your project's folder and delete "bin" and "obj" folders from android project.
Clean your solution and then rebuild it, it may work.
Check your project on Embedded Resource Environment
then try to this step:-
-Delete "obj" "bin"
-Clean Your project
-Re-build project

How to regenerate Resource.designer.cs file Xamarin Android

So I am new to Xamarin studio and have been stuck on a little bit of a frustrating issue. Every time I make a change within the resources file, the Resource.designer.cs file does not regenerate and recognize the new changes. Does anyone know how I can update the changes so that I can interact with newly added widgets? I appreciate the help.
Check your Android's .csproj file and make sure the following AndroidResgenXXXX properties are included within a PropertyGroup (within the Project)
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>

Miscellaneous files in C#/Xamarin.Forms Shared Project

All .cs file in my Xamarin project are Miscellaneous files http://prntscr.com/cp3q4w . I have no Quick Actions and Refactorings support, and it seems like there is somehow missing reference to Xamarin.Forms http://prntscr.com/cp3qzr ,but i dont get compile error for not recognizing xamarin components.
This is Xamarin.Forms Shared project.
Tried with this solution:
i) Clear the cache
ii) Open the solution
iii) Unload all projects
iv) Load Android project and then fix nuget references
v) Once the references were fixed, I loaded the shared project. Now everything seems to work.
But, didn't succeed.
Anyone had similar problem? Any suggestions for solution?
Thanks.
First thing to try if your solution is checked in to source control:
Do a full Git clean to make sure there are no left over files stopping compilation
Clear your NuGet cache. (How to clear NuGet package cache using command line?)
Try again.
If this fails, try this:
Starting a new Visual C# -> Cross Platform -> Mobile App (Xamarin.Forms) solution in Visual Studio 2017. I recommend trying a ".NET Standard" project rather than a "Shared Project".
Make sure the solution compiles and runs to make sure you have all the necessary components for Xamarin Installed.
Do a back up of this clean solution, or commit it to source control.
Upgrade all the NuGet packages if necessary
Pull all the files in from your old solution and see if you get the same problem. Just remember to make sure that the files are added as the correct type of file. For example xaml files must be set to "Embedded resource".
If you still have trouble, please post the error that you get, and upload your solution somewhere so we can have a look.
This also happened to me.
It still does every now and again.
These steps work for me:
Close your solution.
Delete the packages folder from your solution folder or just rename it to packages.old
Open your solution and restore the NuGet packages.
The new class will now show up correctly and your intellisense should work again.
Does anyone have an idea what could cause this though as I don't see any errors when building?

Android land / port layout structure not working

I have included the following folders within my project:
layout
layout-land/
layout-port/
I placed the my main.axml file in all of them, with a couple of tweaks to the UI of course. But when I change the orientation on the device, noting happens.
I'm doing basically the same as this tutorial, but I'm making use of Xamarin and Visual Studio: http://www.how-to-develop-android-apps.com/how-to-make-a-landscape-layout-in-android/
Not really sure what I'm doing wrong?! Could someone please assist?
Okay, so basically I had a folder called layout-normal. This caused the layout-land to be ignored for some or other reason. I removed the folder from the project and it worked!

Categories