Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pinterest like custom GridView

Tags:

android

I am new to android, and I am searching for a logic for grid view like pinterest(homescreen) app that has been build for i-phone. A large no. of images are coming from the server that I need to show in following form with pagination effect i.e loading images on scroll.

image is here

please reply if it is possible other way around. I'll be highly thankful.

like image 822
Raj Kumar Yadav Avatar asked Mar 13 '12 06:03

Raj Kumar Yadav


2 Answers

If you want to perform loading of image on scroll then it will similar to List View.First save all data from WS URL then load on demand Now

Commonsware Endless Adapter For Listview,you can integrate it with GridView too

EndLessAdapter

Another way is to put your grid views in a ViewFlipper and then flip with an animation.

Use setInAnimation() and setOutAnimation() to set the animations and flip the pages with showNext() and showPrevious()

like image 165
Tofeeq Ahmad Avatar answered Oct 21 '22 19:10

Tofeeq Ahmad


Create layout like as follow

<ScrollView...>
<LinearLayout....
   android:id="@+id/linear1"
   orientation="horizontal">

   <LinearLayout....
     android:id="@+id/linear2"
     android:layout_weight="0.33"
     orientation="vertical">

   <LinearLayout....
     android:id="@+id/linear3"
     android:layout_weight="0.33"
     orientation="vertical">

   <LinearLayout....
     android:layout_weight="0.33"
     orientation="vertical">

</LinearLayout>
</ScrollView>

Now add your ImageView dynamically in layouts

linear1 = (LinearLayout) findViewById(R.id.linear1);
linear2 = (LinearLayout) findViewById(R.id.linear2);
linear3 = (LinearLayout) findViewById(R.id.linear3);

for(int i=0;i<n;i++)
{
   ImageView iv = new ImageView(this);
   iv.setImageResource(R.id.icon);

   int j = count % 3;  <---- 
   if(j==0)
       linear1.addView(iv);
   else if(j==1)
       linear2.addView(iv);
   else
       linear3.addView(iv); 
}
like image 41
Vijay Vankhede Avatar answered Oct 21 '22 19:10

Vijay Vankhede