Set Icon to ImageView by icon id and view id - Android User Interface

Android examples for User Interface:ImageView

Description

Set Icon to ImageView by icon id and view id

Demo Code


//package com.java2s;

import android.view.View;
import android.widget.ImageView;

public class Main {
    public static Boolean SetIconId(View parentView, int nViewId,
            int nIconId) {
        ImageView imageView = (ImageView) parentView.findViewById(nViewId);
        if (imageView == null) {
            return false;
        }//from w  w  w .j a va 2 s .com
        imageView.setImageResource(nIconId);
        return true;
    }
}

Related Tutorials