Created
July 25, 2015 14:30
-
-
Save TheFinestArtist/760aeb8dbdf2cd244512 to your computer and use it in GitHub Desktop.
ViewHelper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.graphics.drawable.Drawable; | |
import android.os.Build; | |
import android.view.View; | |
/** | |
* ViewHelper | |
* | |
* Created by TheFinestArtist | |
*/ | |
public class ViewHelper { | |
public static void setBackground(Context context, View view, int id) { | |
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) | |
view.setBackgroundDrawable(context.getResources().getDrawable(id)); | |
else | |
view.setBackground(context.getResources().getDrawable(id)); | |
} | |
public static void setBackground(View view, Drawable d) { | |
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) | |
view.setBackgroundDrawable(d); | |
else | |
view.setBackground(d); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment