Skip to content
Advertisement

Using GridView in XML, getting java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView

Every time I try to start my app it crashes leaving this message in logcat

Caused by: android.view.InflateException: Binary XML file line #15 in com.example.connect3game:layout/activity_main: addView(View, LayoutParams) is not supported in AdapterView

Caused by: java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView

This is my code:

MainActivity.java

JavaScript

activity_main.xml

JavaScript

Advertisement

Answer

your GridView is lacking numColumns property and also its children must have layout_width="match_parent". for example:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement