Java tutorial
//package com.java2s; import android.view.View; import android.widget.ImageView; public class Main { public static void setImageResource(View view, int id, int resId) { ImageView imageView = findViewById(view, id); imageView.setImageResource(resId); } public static <T> T findViewById(View view, int id) { return (T) view.findViewById(id); } }