Forum Xamarin.Android

set image from folder in project

i have folder in my project contains images
how can i set the imageview bind to one of these images using the path

i have the path like : "Resources/Category_one/image_one.png"

how can i display this image using imageview ???

Tagged:

Answers

  • YkshLeoYkshLeo USMember ✭✭✭✭

    You have to add image to the Resources/drawable folder (refer here...).
    Then, you can access them by using:

    Resource.Drawable.NameOfImage
    

    If you want to access them by their original name, you better save them in the Assets folder. Then, you can access them by using the AssetManager:

    AssetManager assetManager = Resources.Assets;
    try {
        InputStream inputStream = assetManager.Open("NameOfImage.png");
            // use the input stream as you want
    }
    catch(IOException ex) {
        Debug.WriteLine(ex.Message);
    }
    
Sign In or Register to comment.