views:

57

answers:

1

Good Morning,

I have a ListView that with alphabetical headers for each letter. I also have an index function that brings the letter headers to the top of the screen.

My problem is when I reach the end of the list setSelection is unable to bring the last few headers to the top because it will not scroll past the end of the list.

My question is this: Is there a way to add a blank space to the end of the screen dependent on screen size? I would like to scroll until the last item in the list is at the top of the listView.

Any help would be appreciated.

Thanks, Josh

A: 

I'm assuming you are using an extension of BaseAdapter to populate your ListView?

There may be a built-in way to do what you are asking, but I don't know of one. If you end up creating it yourself, how about this approach:

  • Return list.size() + EXTRA in getCount()
  • Modify getItem() to return something sane if it asks for an item not in your list
  • Modify getView() to configure the given view as a simple horizontal padding with the same height as the rest of your views if the position index is more than your list size

You would need to fiddle around with the EXTRA constant to see what value is best.

Aaron C