Java tutorial
//package com.java2s; import android.app.Activity; import android.content.Context; import android.graphics.drawable.Drawable; import android.view.View; import android.widget.TextView; public class Main { public static void updateLeft(Context context, View view, int resourceId) { if (view != null && view instanceof TextView) { Drawable drawable = context.getResources().getDrawable(resourceId); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); ((TextView) view).setCompoundDrawables(drawable, null, null, null); } } public static void updateLeft(Activity activity, int viewId, int resourceId) { View view = activity.findViewById(viewId); updateLeft(activity, view, resourceId); } }