java.lang.IllegalArgumentException: parameter must be a descendant of this view

Log信息

java.lang.IllegalArgumentException: parameter must be a descendant of this view
    at android.view.ViewGroup.offsetRectBetweenParentAndChild(ViewGroup.java:4555)
    at android.view.ViewGroup.offsetDescendantRectToMyCoords(ViewGroup.java:4492)
    at android.view.ViewRootImpl.scrollToRectOrFocus(ViewRootImpl.java:2659)
    at android.view.ViewRootImpl.draw(ViewRootImpl.java:2303)
    at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2252)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1882)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:999)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5663)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
    at android.view.Choreographer.doCallbacks(Choreographer.java:587)
    at android.view.Choreographer.doFrame(Choreographer.java:557)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5345)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:855)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:671)
    at dalvik.system.NativeStart.main(Native Method)

bug出现的情况:Android系统4.4.2和4.4.4,在Listview适配子项中存在edittext编辑框,并且数据是超出一屏 。当即点击最后一项中的edittext弹出了软键盘 然后收缩父项后就出现异常。

 

解决方法

public View getView(int position, View convertView, ViewGroup parent) {
    //强制清除当前焦点
    Activity activity = (Activity) getContext();
    View currentFocus = activity.getCurrentFocus();
    if (currentFocus != null) {
        currentFocus.clearFocus();
    }
}

 

posted @ 2017-10-10 14:32  请输入...昵称  阅读(1133)  评论(0编辑  收藏  举报