Android examples for User Interface:View Bitmap
cleanup View With Image
//package com.java2s; import android.annotation.SuppressLint; import android.graphics.drawable.Drawable; import android.os.Build; import android.view.View; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.SeekBar; public class Main { public static View cleanupViewWithImage(View view) { if (view instanceof ImageButton) { ImageButton ib = (ImageButton) view; ib.setImageDrawable(null);/* w ww . j a va2 s .co m*/ } else if (view instanceof ImageView) { ImageView iv = (ImageView) view; iv.setImageDrawable(null); } else if (view instanceof SeekBar) { SeekBar sb = (SeekBar) view; sb.setProgressDrawable(null); sb.setThumb(null); } return setBackgroundDrawable(view, null); } @SuppressWarnings({ "deprecation", "javadoc" }) @SuppressLint("NewApi") public static View setBackgroundDrawable(View view, Drawable drawable) { if (drawable == null) { view.setBackgroundResource(0); return view; } if (Build.VERSION.SDK_INT >= 16) { view.setBackground(drawable); } else { view.setBackgroundDrawable(drawable); } return view; } }