Assuming you are referring to a resource file in Xamarin, you can locate the resource by using its Id as follows:
In your Xamarin project, go to the Resources folder and open the file where your resource Id is defined (e.g. Resource.Designer.cs for Android or Resource.Designer.cs for iOS)
Look for the Id of the resource you want to locate. It should be defined as a constant in the resource file.
For Android, it will be defined as a static integer in the Resource class, for example:
public static int myResource = 2137090000;
For iOS, it will be defined as a static string in the Resource class, for example:
public static string myResource = "myResource.png";
var resource = Resources.GetDrawable(Resource.myResource);
In iOS, you can retrieve the resource using the NSBundle class as follows:
var resource = UIImage.FromBundle(Resource.myResource);
To search for a resource by its name, you can use the Resources class again in Android as follows:
var resourceId = Resources.GetIdentifier("myResourceName", "drawable", PackageName); var resource = Resources.GetDrawable(resourceId);
And in iOS, you can use the NSBundle class as follows:
var resource = UIImage.FromBundle("myResourceName.png");
Note that the way you search for a resource by its name may vary depending on the type of resource (e.g. drawable, layout, string) and the platform you are targeting.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-05-23 11:00:00 +0000
Seen: 7 times
Last updated: Aug 25 '22
What is the process for incorporating std::hash into a class template?
What is the process for adding a class path permanently to the Mac terminal?
How can the __iter__ method of the cursor class in psycopg2 be expanded?
What is the process for obtaining and recording all Linq To Db queries in a database table?
What is the method for directing focus toward the subset within an existing class?
How do I reference media element events located on a ContentView from a ContentPage XAML CS class?
What is the issue when Selenium is unable to locate an element by its class name?
Is there a potential for a conflict between the name of a class and the name of a property?
How to obtain the value of an annotation by using reflection?