Preventing/catching “IllegalArgumentException: parameter must be a descendant of this view” error

后端 未结 15 1488
北恋
北恋 2020-11-27 13:46

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 w

相关标签:
15条回答
  • 2020-11-27 14:17

    My answer is related to most of the answers here, but I just wanted to add that in my case, this crash occurred due to removing a row with an edit text that currently had the focus.

    So all I did was override the remove method of the adapter, and queried whether the removed row contains the current focus edit and if so, clear the focus.

    That solved it for me.

    0 讨论(0)
  • 2020-11-27 14:19

    In case of Expandable List View, if your child items have edit text then you need to change the focusability before descendants for Expandable List View

    expandableListView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
    
    0 讨论(0)
  • 2020-11-27 14:21

    I faced the same problem when using EditText in Recyclerview. After a lot of struggle and trying different option i found out the after deleting the row when my keyboard is opened produces this issue. I solved it by force closing my keyboard and changing notifyItemRemoved(position) with notifyDataSetChanged().

    0 讨论(0)
提交回复
热议问题