0

I'd like to create ListView that can be expandable.

enter image description here enter image description here

So, i found some method, and set listener in listview.

like this.

listView.setOnScrollListener(new OnListViewScrollListener() {
            @Override
            protected void onFlinging() {
                Log.d(TAG, "onFlinging");
            }

            @Override
            protected void onScrollFinished() {
                Log.d(TAG, "onScrollFinished");

            }

            @Override
            protected void onScrolling() {
                Log.d(TAG, "onScrolling");
            }
        });

and here is OnListViewScrollListener.java

public abstract class OnListViewScrollListener implements AbsListView.OnScrollListener {
    private final String TAG = OnListViewScrollListener.class.getSimpleName();
    int mCurrentVisibleItemCount;

    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {
        if(isValidItemCount()){
            switch (scrollState){
                case SCROLL_STATE_FLING :
                    onFlinging();
                    break;

                case SCROLL_STATE_IDLE :
                    onScrollFinished();
                    break;

                case SCROLL_STATE_TOUCH_SCROLL :
                    onScrolling();
                    break;
            };
        }
    }

    @Override
    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        this.mCurrentVisibleItemCount = visibleItemCount;
        Log.d(TAG, "firstVisibleItem,  visibleItemCount, totalItemCount # ["+firstVisibleItem+", "+visibleItemCount+", "+totalItemCount+"]");
    }

    private boolean isValidItemCount() {
        return mCurrentVisibleItemCount > 0;
    }

    protected abstract void onFlinging();
    protected abstract void onScrollFinished();
    protected abstract void onScrolling();
}

But i don't know how to expand listview that is include many rows which is photos.

like gallary.

Please let me know that how to expand listview.

Thanks.

bubu uwu
  • 463
  • 2
  • 12
  • 26

2 Answers2

0

Here is an example of how to resize a view with an Animation. You can use this for both the expanding and collapsing of the ListView.

If you want the ListView to display more detail when expanded (bigger photos, etc), you'll need to call notifyDataSetChanged and return different view in the adapter, once the animation is completed.

Community
  • 1
  • 1
Kevin
  • 1,626
  • 16
  • 30
0

You are talking about something like bottom sheet

https://www.google.com/design/spec/components/bottom-sheets.html?utm_campaign=android_launch_supportlibrary23.2_022216&utm_source=anddev&utm_medium=blog#bottom-sheets-persistent-bottom-sheets

This one is already provieded in the support library 23.2

Long Ranger
  • 5,888
  • 8
  • 43
  • 72