preventing /捕获和QUOT;抛出:IllegalArgumentException:参数必须是这一观点与QUOT的后裔;错误 [英] Preventing/catching "IllegalArgumentException: parameter must be a descendant of this view" error

查看:307
本文介绍了preventing /捕获和QUOT;抛出:IllegalArgumentException:参数必须是这一观点与QUOT的后裔;错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ListView随(多为的EditText S)里面的一些可获得焦点的组件。是的,我知道这是不完全推荐,但在一般情况下,几乎一切工作正常,并重点飞到哪里,它要(有一些调整,我不得不code)。不管怎么说,我的问题是,滚动列表,用手指,然后突然用轨迹球时,有一个奇怪的比赛条件的被显示在输入法键盘时,的。东西一定要出界,并得到回收,在这点上 offsetRectBetweenParentAndChild()方法必须踢,扔抛出:IllegalArgumentException

现在的问题是,这种异常任何块,我可以插入一个try / catch外甩(据我所知)。因此,有两种有效的解决方案,这个问题,无论是:

  1. 有人知道的为什么的这种异常被抛出,以及如何阻止它的发生
  2. 在有人知道如何把一个try / catch块的地方,将至少让我的应用程序生存。据我所知,问题是重点,所以它绝对不应该杀了我的应用程序(这是它在做什么)。我试图重写的ViewGroup 的方法,但是这两个偏移* 方法被标记为final。

堆栈跟踪:

  08-17 18:23:09.825:ERROR / AndroidRuntime(1608):致命异常:主要
08-17 18:23:09.825:ERROR / AndroidRuntime(1608):java.lang.IllegalArgumentException:如果参数必须是这一观点的后代
08-17 18:23:09.825:ERROR / AndroidRuntime(1608):在android.view.ViewGroup.offsetRectBetweenParentAndChild(ViewGroup.java:2633)
08-17 18:23:09.825:ERROR / AndroidRuntime(1608):在android.view.ViewGroup.offsetDescendantRectToMyCoords(ViewGroup.java:2570)
08-17 18:23:09.825:ERROR / AndroidRuntime(1608):在android.view.ViewRoot.scrollToRectOrFocus(ViewRoot.java:1624)
08-17 18:23:09.825:ERROR / AndroidRuntime(1608):在android.view.ViewRoot.draw(ViewRoot.java:1357)
08-17 18:23:09.825:ERROR / AndroidRuntime(1608):在android.view.ViewRoot.performTraversals(ViewRoot.java:1258)
08-17 18:23:09.825:ERROR / AndroidRuntime(1608):在android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
08-17 18:23:09.825:ERROR / AndroidRuntime(1608):在android.os.Handler.dispatchMessage(Handler.java:99)
08-17 18:23:09.825:ERROR / AndroidRuntime(1608):在android.os.Looper.loop(Looper.java:130)
08-17 18:23:09.825:ERROR / AndroidRuntime(1608):在android.app.ActivityThread.main(ActivityThread.java:3683)
08-17 18:23:09.825:ERROR / AndroidRuntime(1608):在java.lang.reflect.Method.invokeNative(本机方法)
08-17 18:23:09.825:ERROR / AndroidRuntime(1608):在java.lang.reflect.Method.invoke(Method.java:507)
08-17 18:23:09.825:ERROR / AndroidRuntime(1608):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:839)
08-17 18:23:09.825:ERROR / AndroidRuntime(1608):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-17 18:23:09.825:ERROR / AndroidRuntime(1608):在dalvik.system.NativeStart.main(本机方法)
 

解决方案

有关它的价值(或任何人绊倒在此),我已经放弃了这项活动的ListView方法。除了随机崩溃,这几乎是不可能正确地获得焦点的行为不设置 windowSoftInputMode =adjustPan将打开一堆其他罐头蠕虫的。相反,我只是去了一个简单的滚动型,并且一直很大。

I have a ListView with some focusable components inside (mostly EditTexts). Yeah, I know this isn't exactly recommended, but in general, almost everything is working fine and the focus goes where it has to go (with a few tweaks I had to code). Anyway, my problem is that there's a weird race condition when scrolling the list with your finger and then suddenly using the trackball when the IME keyboard is being displayed. Something must go out of bounds and get recycled at which point the offsetRectBetweenParentAndChild() method must kick in and throw the IllegalArgumentException.

The problem is that this exception is thrown outside of any block in which I can insert a try/catch (as far as I know). So there are two valid solutions to this question, either:

  1. Someone knows why this exception being thrown and how to stop it from happening
  2. Someone knows how to put a try/catch block somewhere that will at least let my application survive. As far as I know the problem is that of focus, so it definitely shouldn't kill my application (which is what it's doing). I tried overriding the ViewGroup's methods but those two offset* methods are marked as final.

Stack trace:

08-17 18:23:09.825: ERROR/AndroidRuntime(1608): FATAL EXCEPTION: main
08-17 18:23:09.825: ERROR/AndroidRuntime(1608): java.lang.IllegalArgumentException: parameter must be a descendant of this view
08-17 18:23:09.825: ERROR/AndroidRuntime(1608):     at android.view.ViewGroup.offsetRectBetweenParentAndChild(ViewGroup.java:2633)
08-17 18:23:09.825: ERROR/AndroidRuntime(1608):     at android.view.ViewGroup.offsetDescendantRectToMyCoords(ViewGroup.java:2570)
08-17 18:23:09.825: ERROR/AndroidRuntime(1608):     at android.view.ViewRoot.scrollToRectOrFocus(ViewRoot.java:1624)
08-17 18:23:09.825: ERROR/AndroidRuntime(1608):     at android.view.ViewRoot.draw(ViewRoot.java:1357)
08-17 18:23:09.825: ERROR/AndroidRuntime(1608):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1258)
08-17 18:23:09.825: ERROR/AndroidRuntime(1608):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
08-17 18:23:09.825: ERROR/AndroidRuntime(1608):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-17 18:23:09.825: ERROR/AndroidRuntime(1608):     at android.os.Looper.loop(Looper.java:130)
08-17 18:23:09.825: ERROR/AndroidRuntime(1608):     at android.app.ActivityThread.main(ActivityThread.java:3683)
08-17 18:23:09.825: ERROR/AndroidRuntime(1608):     at java.lang.reflect.Method.invokeNative(Native Method)
08-17 18:23:09.825: ERROR/AndroidRuntime(1608):     at java.lang.reflect.Method.invoke(Method.java:507)
08-17 18:23:09.825: ERROR/AndroidRuntime(1608):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-17 18:23:09.825: ERROR/AndroidRuntime(1608):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-17 18:23:09.825: ERROR/AndroidRuntime(1608):     at dalvik.system.NativeStart.main(Native Method)

解决方案

For what it's worth (or whoever stumbles on this), I've abandoned the ListView approach for this Activity. Aside from the random crashes, it's almost impossible to get the focus behavior correctly without setting the windowSoftInputMode="adjustPan" which opens a bunch of other cans of worms. Instead, I just went for a "simple" ScrollView and that has been working great.

这篇关于preventing /捕获和QUOT;抛出:IllegalArgumentException:参数必须是这一观点与QUOT的后裔;错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆