zoukankan      html  css  js  c++  java
  • 使用SafeViewFlipper避免ViewFlipper交替时Crash

    使用SafeViewFlipper避免ViewFlipper交替时Crash

    ViewFilpper 是Android官方提供的一个View容器类,继承于ViewAnimator类,用于实现页面切换。当我们界面重叠较多的时候,ViewFilpper 容易崩溃,直接导致程序Crash。

    我们可以使用自定义的SafeViewFlipper来避免这一问题。

    import android.content.Context;
    import android.util.AttributeSet;
    import android.widget.ViewFlipper;
    
    public class SafeViewFlipper extends ViewFlipper {
    
        public SafeViewFlipper(Context context) {
            super(context);
        }
    
        public SafeViewFlipper(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        @Override
        public void onDetachedFromWindow() {
            try {
                super.onDetachedFromWindow();
            }
            catch (IllegalArgumentException e) {
                // This happens when you're rotating and opening the keyboard that the same time
                // Possibly other rotation related scenarios as well
                stopFlipping();
            }
        }
    }
  • 相关阅读:
    UVA11375
    uva11806(容斥原理)
    uva10325(容斥原理)
    hdu4135(容斥原理)
    CF798
    多线程
    (转载)SVN 提交操作缩写(A D M R) .
    上不了网,如何判断
    (转载)myeclipse项目名称重命名
    mysql模糊查询
  • 原文地址:https://www.cnblogs.com/duanweishi/p/4518364.html
Copyright © 2011-2022 走看看