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

Source: Internet
Author: User

Exception information:

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

Cause of Error:

This error occurs primarily when a ListView or other container control, such as a viewgroup, temporarily removes a child view because it slips, but does not remove the focus on the child view, so it does not revert to the original view when the ListView is sliding back to its original position, Causes the exception to be generated, the specific source code analysis can see the reference link [2]

Workaround:

The solution is to clear the focus of the item in the ListView, and here is the code from the reference link [1] that solves the problem:

protected  class Myscrolllistener implements Onscrolllistener {        @Override         Public void onscroll(Abslistview view,intFirstvisibleitem,intVisibleItemCount,intTotalitemcount) {// do nothing}@Override         Public void onscrollstatechanged(Abslistview view,intScrollstate) {if(Scroll_state_touch_scroll = = scrollstate) {View Currentfocus = Getcurrentfocus ();if(Currentfocus! =NULL) {Currentfocus.clearfocus (); }            }        }    }

This code is for the ListView set Scrolllistener monitoring, so that the ListView can be scrolled in the time to clear out the focus of the Childview, you can also refer to the reference link [1] other solutions, This problem occurs in my code because my ListView has a headerview in it, there is a edittext input box in the Headerview, and this edittext gets the focus, inflate So my ListView will have this exception when I scroll down and back to the top of the ListView, my solution is simpler, just remove the focus of Headerview EditText (Medittext.clearfocus () ;)。

Reference Links:

http://stackoverflow.com/questions/7100555/preventing-catching-illegalargumentexception-parameter-must-be-a-descendant-of
Http://blog.sina.com.cn/s/blog_5704bfaf0102v3bn.html
Http://www.cnblogs.com/LIANQQ/p/4026560.html
Http://www.educity.cn/wenda/100840.html
http://blog.csdn.net/a443453087/article/details/8079990

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Java.lang.IllegalArgumentException:parameter must is a descendant of this view

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.