1

I am developing an application which consists on scroll-change-listener,Here is my problem, I am getting the Number of items for the server.Until here every thing works fine to me.

1.IF i am showing the 10 values in the list-view,that 10 values only should stream.

2.When Scroll state is changed the reaming item should hit server.

3.Below is my code .

@Override
    public void onScroll(AbsListView view, int firstVisibleItem,int visibleItemCount, int totalItemCount) {
        if (visibleItemCount < 1)
            return;

        streaming.clear();
        int firstPoisitionValue = symbolList.getFirstVisiblePosition();
        int lastPositionValue = symbolList.getLastVisiblePosition();

        WatchListData row;
        String symbol;
        for (int i = firstPoisitionValue; i <= lastPositionValue; i++) {
            row = model.get(i);
            symbol=row.getSymbol();
            Log.w("Hello Android", "Symbol Value ::>"+symbol);
            streaming.add(symbol);
        }

        if (streamFlag) {
            System.out.println("calling the request");
            streamingRequest("quote", streamingSymbols);
            streamFlag = false;
        }

    }


    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {

        pauseStreaming();
        if(scrollState == SCROLL_STATE_IDLE){
            streamingRequest("quote", streamingSymbols);
        }

Thanks, Nikhilreddy.

NikhilReddy
  • 6,904
  • 11
  • 38
  • 58

1 Answers1

0

You can do this by using onScroll Listener. Using this listener When scroll reaches the end you can load new items to the list. refer this link. It may help you.Dynamic listView

Community
  • 1
  • 1
prabhu
  • 1,158
  • 1
  • 12
  • 27