<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/allview"
>
@Override
protected void onDestroy() {
cleanupView(findViewById(R.id.allview));
super.onDestroy();
}
指定したビュー階層内のドローワブルをクリアする。
(ドローワブルをのコールバックメソッドによるアクティビティのリークを防ぐため)
@param view
public static final void cleanupView(View view) {
if(view instanceof ImageButton) {
ImageButton ib = (ImageButton)view;
ib.setImageDrawable(null);
} 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);
}
view.setBackgroundDrawable(null);
if(view instanceof ViewGroup) {
ViewGroup vg = (ViewGroup)view;
int size = vg.getChildCount();
for(int i = 0; i < size; i++) {
cleanupView(vg.getChildAt(i));
}
}
}
https: