Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GridView.LayoutParams does not exist, Android code breaks

I'm following along the HelloWorld tutorials for Android but when I do the GridView exercise (http://developer.android.com/resources/tutorials/views/hello-gridview.html)

I found that if I comment out the line: imageView.setLayoutParams(new GridView.LayoutParams(85, 85));

Then everything works. I did some research and found that GridView.LayoutParams does not exist. Am I doing something wrong? Is the tutorial broken?

like image 655
Steve Avatar asked Jul 10 '26 13:07

Steve


2 Answers

I did some research and found that GridView.LayoutParams does not exist.

Where did you research? GridView.LayoutParams does exist. LayoutParams is a class inherited from the ViewGroup class, which is the super class of GridView.

Edit:

Just took a look and it seems that, as you said, LayoutParams are not accessible from GridView. Use AbsListView.LayoutParams instead.

like image 114
Cristian Avatar answered Jul 12 '26 03:07

Cristian


GridView.LayoutParams is actually AbsListView.LayoutParams, so you can safely use that instead.

like image 36
zrgiu Avatar answered Jul 12 '26 03:07

zrgiu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!