14  January
28

StaggeredGridView

This is a modified version of Android’s experimental StaggeredGridView. The StaggeredGridView allows the user to create a GridView with uneven rows similar to how Pinterest looks. Includes own OnItemClickListener and OnItemLongClickListener, selector, and fixed position restore.

To use StaggeredGridView in your projects, simply add this project to your workspace then add it as a library project to your current project.

By Maurycy Wojtowicz

Demo link: https://github.com/maurycyw/StaggeredGridViewDemo

Download from GitHub

 

28 comments on “StaggeredGridView”

  1. Adi Reply

    Hi, Really interesting. But cannot found the “com.origamilabs.library.views.StaggeredGridView”.
    Any help?

    Thanks

  2. Waheed Reply

    Hello,

    I tried to use StaggeredGridView within a Fragment in an ActionBar , the MainActivity extends FragmentActivity and implements
    ActionBar.TabListener. And I have another class extends Fragment but I always get NullPointerException in the following line in my “Fragment” class:
    StaggeredGridView gridView = (StaggeredGridView) this.getView().findViewById(R.id.staggeredGridView1);

    Could you please help my in using StaggeredGridView within a Fragment instead in Activity?

    Thank you & Best Regards

  3. Waheed Reply

    I’ve solved the problem ,
    Yes it takes long long time but finally it now works , the problem is only that I have to define a view object in onCreaView method of the fragment, as this line:

    View view = inflater.inflate(R.layout.fragment_featured,container, false);

    then use this line:

    StaggeredGridView gridView = (StaggeredGridView)view.findViewById(R.id.staggeredGridView1);

    instead of :

    StaggeredGridView gridView = (StaggeredGridView) this.getView().findViewById(R.id.staggeredGridView1);

    Thank you,,,

  4. saleeh Reply

    Any one have any how to add on setScrollListener
    i didn’t find a way to add that

  5. Tamilselvan Reply

    It seems really nice.,
    But. I cannot add this library to my code which i have coded using ActionBar sherlock and sliding menu lib.
    My code working fine with action bar and sliding menu., but when i tried to add this library to my project it gives error as “JAR MISMATCH- ANDROID SUPPORT LIB V4 IN STAGGERED GRID VIEW”
    can you please help. how can i use this library when i am using sherlock.?
    Thanks in advance:-)

    • Gates Reply

      Delete Support Lib V4 in folder libs from the procject. not from Staggeredgridview library

      • Alus

        There is a still conflict with sherlock actionbar lib v4.

  6. Gates Reply

    Hei, I did all configuration well with no error. But no Image shown, because I don’t know how to add the images to StaggeredGridView…

    Anyone can help?

    • daisy Reply

      I have the same problem with you, have you solved it?

      • Gates

        Still cannot :( , have tried with ArrayAdapter and ImageAdapter as normal GridView works. but still shown nothing.

    • daisy Reply

      Did you try SimpleAdapter? I have changed the StaggeredGirdAdapter into subclass of SimpleAdapter.

  7. Rami Reply

    Hi,

    I using this library and I’m getting some weird behavior.
    I’m using ResourceCursorAdapter in order to populate the grid,
    The problem I see is that the Item View (i.e. the ScaleImageView in your example) is stretched.
    My grid item is some relative layout with some TextViews and two ImageViews.
    Does anyone ran into this problem?

  8. techflag Reply

    hava any to pull to refreash?

  9. Bin Reply

    I can’t find onscrollListener too, have any method to help me know the gridview have scroll to bottom ?

  10. rovak Reply

    How does one set an onClick listener to this? Any help is great.

  11. Tony Reply

    Can anyone tell me if it is possible to add animations to this view so that it works similar to Google Plus?
    I would like to have the app add additional views when you get to the bottom of the scroll and have them float up from the bottom as in Google Plus. I tried making some changes to my getView() function along the lines of several different listview animation examples I have seen, but all of them resulted in a null exception in the choreographer, so I am not sure if it just can’t be done there.

  12. Manish Reply

    I try to handle click event using below code:
    gridView.setOnItemClickListener(new OnItemClickListener() {

    @Override
    public void onItemClick(StaggeredGridView parent, View view, int position,
    long id) {
    // TODO Auto-generated method stub

    }
    });
    But it show me error that
    The method setOnItemClickListener(StaggeredGridView.OnItemClickListener) in the type StaggeredGridView is not applicable for the arguments (new AdapterView.OnItemClickListener(){})

    Please help me.

    • Manish Reply

      Hi
      I solve my own problem just write below code:
      gridView.setOnItemClickListener(new StaggeredGridView.OnItemClickListener() {

      @Override
      public void onItemClick(StaggeredGridView parent, View view, int position,
      long id) {
      // TODO Auto-generated method stub

      }
      });

  13. Gioan Doan Reply

    I not using List url ?
    I not can add item for my list
    Thanks

  14. Keyur Reply

    Hi this is awesome, but I am facing with below error

    android-apt-compiler: [StaggeredGridViewDemo] /Users/keyur/Android/StaggeredGridViewDemo/res/layout/activity_main.xml:9: error: No resource identifier found for attribute ‘numColumns’ in package ‘com.example.staggeredgridviewdemo’

    How to resolve this issue ?

    • Keyur Reply

      Finally was able to resolve this issue with below change in manifest file of demo.

      old value
      xmlns:staggered=”http://schemas.android.com/apk/res-auto”

      Replace to new value
      xmlns:staggered=”http://schemas.android.com/apk/lib/com.origamilabs.library”

  15. david Reply

    anyone do it success?

Leave a comment

Please wait...