Alex Troto
Alex Troto

Reputation: 661

obtainStyledAttributes in monodroid

I'm trying to replicate monodroid example for gallery tutorial. But the example is missing one important point : how to set the background style of ImageView. On Android tutorial we have the following code :

 TypedArray attr = mContext.obtainStyledAttributes(R.styleable.HelloGallery);
    mGalleryItemBackground = attr.getResourceId(R.styleable.HelloGallery_android_galleryItemBackground, 0);
    attr.recycle();

    ....

    imageView.setBackgroundResource(mGalleryItemBackground);

I have no idea how should I replicate it in monodroid ! Thanks in advance, Alex

Upvotes: 0

Views: 538

Answers (1)

Greg Shackles
Greg Shackles

Reputation: 10139

You can use the ImageView.SetImageResource(int) method to load an image from a resource Id.

Xamarin also has a Gallery sample up on their site that might be more useful to you than the Java version.

Upvotes: 1

Related Questions