1

Good afternoon,

I have a list view that show a list of items...well not all of them but they are all there. Rather than let the user scroll up / down the requirement asks for and up / down buttons. I have everything handled quite well EXCEPT how to advance the ListView. Say I'm looking at item 3 in the list. The user hits next...I want to ListView to advance to item 4. I am keeping track internally of which page they are on for incrementing / decrementing. I was expecting to find something like this but no dice.

ListView.MoveNext();

or

ListView.Move(int);

Per Brayden's suggestion I tried the accepted solution here: Maintain/Save/Restore scroll position when returning to a ListView and it did not APPEAR to scroll the list....i.e. it stayed on the first list item. I also tried setSelection.

Here is my code:

public void btn_NextClick(View vw_Current) 
{
    //increment page count 1
    i_PageTracker ++;

    //advance to next record
    //int x = lstvw_LiftData.getFirstVisiblePosition();
    View v = lstvw_LiftData.getChildAt(0);
    int top = (v == null) ? 0 : v.getTop();

    lstvw_LiftData.setSelectionFromTop(i_PageTracker, top);
    //lstvw_LiftData.setSelection(i_PageTracker);
 }

Based upon Vladimir's success and my lack thereof I wanted to provide some additional info that I thought irrelevant but....

I've extended the SimpleAedapter and override the getView. I also have a DataBinder to populate TextViews with certain data from the data object.

Interestingly when I set a breakpoint in the getView of the DataAdapter and the setViewValue of the binder at load we hit them as appropriate. However when the next button is clicked we do not hit them which I would expect if the list was advancing to the next position....hmmmm I wonder....I have another Idea....be right back.

I figured it out....but I don't know what to do about it. See not knowing what I am doing I shot myself. I ONLY want to see one item in the list at a time and I don't want the user to be able to scroll. Well what I did to accomplish that was to override getCount in the DataAdapter and return a 1. This SEEMED to be the answer as only one item displayed cool! But then overriding getCount also means there is only one item to display so we never advance...there's nothing to advance to.

So what I want to know is this. How do I keep the user from being able to scroll and force them to use the navigation button. Do I handle the scroll event and return null?

Community
  • 1
  • 1
GPGVM
  • 4,659
  • 8
  • 50
  • 90
  • 1
    See this question: http://stackoverflow.com/questions/3014089/scroll-to-a-position-in-a-listview – Brayden May 21 '12 at 22:13
  • Are you sure `btn_NextClick()` gets called? I've just tried `int position = _listView.getFirstVisiblePosition(); try { _listView.setSelection(position + 1); } catch (Exception e) {}` and it works perfectly – Vladimir May 22 '12 at 09:53
  • Yeah it does as the breakpoints get hit. – GPGVM May 22 '12 at 11:50

1 Answers1

0

I figured it out....but I don't know what to do about it. See not knowing what I am doing I shot myself. I ONLY want to see one item in the list at a time and I don't want the user to be able to scroll. Well what I did to accomplish that was to override getCount in the DataAdapter and return a 1. This SEEMED to be the answer as only one item displayed cool! But then overriding getCount also means there is only one item to display so we never advance...there's nothing to advance to.

So what I want to know is this. How do I keep the user from being able to scroll and force them to use the navigation button. Do I handle the scroll event and return null?

GPGVM
  • 4,659
  • 8
  • 50
  • 90