安卓基础备忘

基础备忘

ViewPager

Android:ViewPage使用教程

常见报错

java.lang.IllegalArgumentException: pointerIndex out of range
The investigation found that this was a ViewPager of Android‘s bug, which occasionally happens when the user performs multitouch operations. The problem persists until at least Android 4.4. The solution is simple, overwriting the ViewPager‘s onTouchEvent and onInterceptTouchEvent methods, and the catch exception


 @Override
    public boolean onTouchEvent(MotionEvent ev) {
        try {
            return super.onTouchEvent(ev);
        } catch (IllegalArgumentException ex) {
            ex.printStackTrace();
        }
        return false;
    }
 
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        try {
            return super.onInterceptTouchEvent(ev);
        } catch (IllegalArgumentException ex) {
            ex.printStackTrace();
        }
        return false;
    }

FastJson

Java 语言 ArrayList 和 JSONArray 相互转换

//ArrayList 转成 JSONArray
      studentJsonArray = JSONArray.parseArray(JSON.toJSONString(studentList));
      System.out.println("\n方式 6: " + studentJsonArray.toJSONString());

//JSONArray 转成 ArrayList

        studentList = JSONArray.parseArray(studentJSONArray.toJSONString(), Student.class);
        studentList.forEach(student -> System.out.println("stundet info: " + student));

Java中用fastjson对String、JSONObject、JSONArray相互转换

安卓基础备忘

上一篇:了解SPA-Single Page App


下一篇:WAF的简单介绍及实现