Unable to start activity:UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView

前端 未结 4 1409
南方客
南方客 2020-11-30 04:21

I want to write a ListView in basic format but I get an error:

UnsupportedOperationException: addView(View, LayoutParams) is not supported in Ad         


        
4条回答
  •  粉色の甜心
    2020-11-30 05:17

    If you're like me and totally skipped over the answer I needed in @Luksprog's answer because it's buried in it, try using adding the third parameter to the inflate method, also mentioned here:

    inflater.inflate(R.layout.group_row, parent, false);
    

    Don't use true instead of false or you will get the same error that brought you here, because it's trying to attach/add it to the parent, hence the addView is not supported in AdapterView error.

提交回复
热议问题