Android examples for User Interface:ImageView
set Image to ImageView by resource id
//package com.java2s; import android.app.Activity; import android.graphics.Bitmap; import android.support.annotation.DrawableRes; import android.support.annotation.IdRes; import android.view.View; import android.widget.ImageView; public class Main { public static void setImage(Bitmap bitmap, View parent, @IdRes int viewId) { ImageView imageView = findView(parent, viewId); imageView.setImageBitmap(bitmap); }/* w ww. j a v a2 s. co m*/ public static void setImage(@DrawableRes int drawableId, View parent, @IdRes int viewId) { ImageView view = findView(parent, viewId); view.setImageResource(drawableId); } public static <T extends View> T findView(View parent, @IdRes int viewId) { return (T) parent.findViewById(viewId); } public static <T extends View> T findView(Activity activity, @IdRes int viewId) { return (T) activity.findViewById(viewId); } }