Error java. Lang. illegalargumentexception: parameter must be a descendant of this view Solution

Source: Internet
Author: User

Bug information:

10-16 17:27:20. 250: D/androidruntime (14662): Shutting Down VM
10-16 17:27:20. 250: W/dalvikvm (14662): threadid = 1: thread exiting with uncaught exception (group = 0x40a5e228)
10-16 17:27:20. 250: E/androidruntime (14662): Fatal exception: Main
10-16 17:27:20. 250: E/androidruntime (14662): Java. Lang. illegalargumentexception: parameter must be a descendant of this view
10-16 17:27:20. 250: E/androidruntime (14662): at Android. View. viewgroup. offsetrectbetweenparentandchild (viewgroup. Java: 4460)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. View. viewgroup. offsetdescendantrecttomycoords (viewgroup. Java: 4397)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. widget. horizontalscrollview. iswithindeltaofscreen (horizontalscrollview. Java: 1054)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. widget. horizontalscrollview. onsizechanged (horizontalscrollview. Java: 1415)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. View. View. setframe (view. Java: 11442)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. View. View. layout (view. Java: 11353)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. View. viewgroup. layout (viewgroup. Java: 4531)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. widget. framelayout. onlayout (framelayout. Java: 431)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. View. View. layout (view. Java: 11359)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. View. viewgroup. layout (viewgroup. Java: 4531)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. widget. linearlayout. setchildframe (linearlayout. Java: 1628)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. widget. linearlayout. layoutvertical (linearlayout. Java: 1486)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. widget. linearlayout. onlayout (linearlayout. Java: 1399)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. View. View. layout (view. Java: 11359)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. View. viewgroup. layout (viewgroup. Java: 4531)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. widget. framelayout. onlayout (framelayout. Java: 431)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. View. View. layout (view. Java: 11359)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. View. viewgroup. layout (viewgroup. Java: 4531)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. View. viewrootimpl. extends mtraversals (viewrootimpl. Java: 1665)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. View. viewrootimpl. handlemessage (viewrootimpl. Java: 2695)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. OS. handler. dispatchmessage (handler. Java: 99)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. OS. Looper. Loop (Looper. Java: 154)
10-16 17:27:20. 250: E/androidruntime (14662): at Android. App. activitythread. Main (activitythread. Java: 4974)
10-16 17:27:20. 250: E/androidruntime (14662): At java. Lang. Reflect. method. invokenative (native method)
10-16 17:27:20. 250: E/androidruntime (14662): At java. Lang. Reflect. method. Invoke (method. Java: 511)
10-16 17:27:20. 250: E/androidruntime (14662): At com. Android. Internal. OS. zygoteinit $ methodandargscaller. Run (zygoteinit. Java: 784)
10-16 17:27:20. 250: E/androidruntime (14662): At com. Android. Internal. OS. zygoteinit. Main (zygoteinit. Java: 551)
10-16 17:27:20. 250: E/androidruntime (14662): At Dalvik. system. nativestart. Main (native method)

Scenario Description:

Click a book in the area outside the screen to enter the reading module on a shelf written in listview. The system will throw the above crash message when it returns. If the book is not in the area outside the screen, it will not crash.

Analysis and Solution:

Parameter must be a descendant of this view indicates that this parameter must be the descendant of this view...

Because there is a horizontalscrollview nested outside my listview, it is very likely that they are caused by two conflicts. Track and view the source code and analysis log information of the horizontalscrollview. prerequisites for this bug: when the listview scrolls down and returns the result, the onsizechanged () method of horizontalscrollview is called. The findfocus method is called in the onsizechanged () method to obtain the view with the current focus in the returned interface. From the above sentence, we can see that the key point is on this view. If it is horizontalscrollview
Will not crash, so let the program return focus directly on a specified view. At this time, I kept listview focused and overwritten its isfocused method to keep returning true. The problem was solved !!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.