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   www. j a v  a2  s  .  c o m*/
        imageView.setImageResource(nIconId);
        return true;
    }
}

Related Tutorials