Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.app.Activity;

import android.widget.ImageView;
import android.widget.LinearLayout;

public class Main {
    public static void addResourceImage(Activity activity, LinearLayout layout, int imgResource, int width,
            int height) {
        ImageView image = new ImageView(activity);
        image.setImageResource(imgResource);
        if (width > 0)
            image.setMaxWidth(width);
        if (height > 0)
            image.setMaxHeight(height);
        image.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        layout.addView(image);
    }
}