Android: Unable to destroy activity

后端 未结 4 1900
野的像风
野的像风 2021-01-04 13:31

I am using the following code to removes childs on every viewgroup:

protected void onDestroy() {
    super.onDestroy();
    this.liberarMemoria();
}

public          


        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-04 13:57

    Verify if your ViewGroup isn't a instance of AdapterView.

    Do something like that:

    if (!(view instanceof AdapterView))
        ((ViewGroup) view).removeAllViews();
    

    So, on your code:

    if (view instanceof ViewGroup) {
        for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
            unbindDrawables(((ViewGroup) view).getChildAt(i));
        }
        if (!(view instanceof AdapterView))
            ((ViewGroup) view).removeAllViews();
    }
    

提交回复
热议问题