Android examples for android.app:Activity
set Background
import android.app.Activity; import android.graphics.drawable.Drawable; import android.view.View; public class Main{ public static void setBackground(Activity activity, int viewID, int backgroundID) { Drawable background = activity.getResources().getDrawable( backgroundID);//from ww w . java2 s . co m View view = (View) activity.findViewById(viewID); int sdk = android.os.Build.VERSION.SDK_INT; if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { view.setBackgroundDrawable(background); } else { view.setBackground(background); } } }