3

Imagine I'm implementing a simple TODO app with active and inactive elements. These elements are separated in two lists (a list for active elements, another list for inactive elements). I already implemented an adapter which handles the two list views to show the inactive elements on top and the active elements below.

My question is, how can I implement the following (see picture below): First of all I like to display the active elements only. When the user reaches the top of that list view he/she can pull down the list to unlock the inactive elements. The unlocking should be similar to the usual content refreshing like in Google Mail app or the PullToRefresh implementation of Chris Banes (So far I'm using the PullToRefresh implementation and I can trigger that event when I pull down for a distance of 50% of the screen size). The part I do have problems with is to smoothly scroll in the list view of the inactive elements.

unlocking hided elements

I guess I need the following steps:

(1) Tell my adapter that it should stop scrolling at the position of the first active element. Do I need to set the inactive elements list view to Visible.GONE for that??

(2) When the user pulls down for a distance of 50% I need to unlock the list view of inactive elements. I think I could use Visible.VISIBLE for that part, but I need to keep the current scroll position while calling adapter.notifyDataSetChanged(). I like to avoid that the adapter jumps on top of the list.

Any suggestions how I can do that? Another idea I had was to use to fragments, each showing a single list view. After pulling down the first list view the fragment of the inactive elements would scroll down. But I think that want work as smooth as I expect it :-)

I'ld appreciate any help!

Best regards, Michael

Michael
  • 3,982
  • 4
  • 30
  • 46

0 Answers0