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