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.graphics.drawable.Drawable;

import android.os.Build;

import android.view.View;

public class Main {
    /**
     * In API Level 16, {@link View#setBackgroundDrawable(Drawable)} was
     * replaced by {@link View#setBackground(Drawable)}. You can use this method
     * to use the refactored method name from API Level 16 on but fall back to
     * the old one for compatibility.
     **/
    @SuppressWarnings("deprecation")
    public static void setBackground(View view, Drawable drawable) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            view.setBackground(drawable);
        } else {
            view.setBackgroundDrawable(drawable);
        }
    }
}