Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.annotation.SuppressLint;

import android.content.Context;

import android.os.Build;

import android.widget.TextView;

public class Main {
    @SuppressLint("NewApi")
    public static void setTextColor(Context ctx, TextView view, int id) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            view.setTextColor(ctx.getResources().getColor(id, ctx.getTheme()));
        } else {
            view.setTextColor(ctx.getResources().getColor(id));
        }
    }

    public static int getColor(Context ctx, int id) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            return ctx.getResources().getColor(id, ctx.getTheme());
        } else {
            return ctx.getResources().getColor(id);
        }
    }
}