Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.view.View; public class Main { public static void setBackgroundColor(Context ctx, View view, boolean night, int lightResId, int darkResId) { view.setBackgroundColor(ctx.getResources().getColor(night ? darkResId : lightResId)); } }