0

i put gridview inside scrollview using Helper class

public class Helper {
public static void getListViewSize(GridView myListView) {
    ListAdapter myListAdapter = myListView.getAdapter();
    if (myListAdapter == null) {
        // do nothing return null
        return;
    }
    // set listAdapter in loop for getting final size
    int totalHeight = 0;
    for (int size = 0; size < myListAdapter.getCount(); size++) {
        View listItem = myListAdapter.getView(size, null, myListView);
        listItem.measure(0, 0);
        totalHeight += listItem.getMeasuredHeight();
    }
    // setting listview item in adapter
    ViewGroup.LayoutParams params = myListView.getLayoutParams();
    params.height = totalHeight
            + (myListView.getHeight() * (myListAdapter.getCount() - 1));
    myListView.setLayoutParams(params);
    // print height of adapter on log
    Log.e("height of listItem:", String.valueOf(totalHeight));
}
}

And use this class as

adapter = new RSSReaderGridAdapter(context, mostLatestItems);
    gridView.setAdapter(adapter);
    Helper.getListViewSize(gridView);

It works fine..but when i scroll page scrolling not stops at last item of gridview...it keep scrolling..

Yogi
  • 63
  • 2
  • 14

1 Answers1

0

Maybe the ScrollView is scrolled . If want to scroll GridView,you should override "onInterceptTouchEvent".

John
  • 1
  • @Yogi .GridView and ScrollView both have scrolling mechanism.If you put a GridView inside a ScrollView , their scrolling mechanisms will conflict. http://stackoverflow.com/questions/9586032/android-difference-between-onintercepttouchevent-and-dispatchtouchevent – John Jul 16 '14 at 03:07
  • Scroll mechanism working properly but i m talking about extra space at bottom – Yogi Jul 16 '14 at 03:45