Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fill a gridview in XML

I have a gridview that just needs to hold 4 buttons, how ever I keep getting an operation not supported in AdapterView error when executing. Can you even fill a gridview through xml?

like image 946
ahodder Avatar asked Feb 25 '23 09:02

ahodder


1 Answers

You cannot add children to a GridView in XML. You need to create an appropriate Adapter and associate it with the GridView via setAdapter().

Most likely, if you only have four buttons, you do not want a GridView in the first place.

like image 193
CommonsWare Avatar answered Mar 05 '23 16:03

CommonsWare