Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android heterogeneous gridview like pinterest? [closed]

Is it possible to create pinterest like layout on Android using GridView? I want to create image gallery using GridView but I am not sure if it is good solution. I do not want create three LinearLayouts (I think that this solution is not good: Pinterest style listview or gridview in android)

Any ideas ;)?

enter image description here

like image 902
radzio Avatar asked Jul 31 '12 09:07

radzio


People also ask

What is a GridView?

A GridView is a type of AdapterView that displays items in a two-dimensional scrolling grid. Items are inserted into this grid layout from a database or from an array.

What is the use of adapter in GridView?

The main function of the adapter in GridView is to fetch data from a database or array and insert each piece of data in an appropriate item that will be displayed in GridView. This is how the GridView structure looks like. Note that we are going to implement this project using the Java language.

How to display grid items in GridView using XML?

Create an XML file for each grid item to be displayed in GridView. Click on the app > res > layout > Right-Click > Layout Resource file and then name the file as card_item. Below is the code for the card_item.xml file.

What is the difference between numcolumns and horizontalspacing in Android GridView?

android:numColumns: This attribute of GridView will be used to decide the number of columns that are to be displayed in Grid. android:horizontalSpacing: This attribute is used to define the spacing between two columns of GridView. android:verticalSpacing: This attribute is used to specify the spacing between two rows of GridView.


1 Answers

I've been playing with this also (used LinearLayout) but at the end I had lot of problems with memory consumption (especially when I had to reload the items). I settled on simple solution which uses two synchronized ListViews. This way I can exploit internal caching which helps a lot. To do this I had to use OnTouchListener and OnScrollListener who synchronize lists. Here's an example:

https://github.com/vladexologija/PinterestListView

enter image description here

like image 101
vladexologija Avatar answered Sep 25 '22 09:09

vladexologija