0

I have a ListView in android in which each row contains year from 2000 to 2014. I want a functionality such that, when user pinch zoom on an year, this view should convert to a ListView, which contains detail related to that year only.

For example, when I pinch zoom on 2012, this listview of year should convert to a another Listview which contains month of 2012, in which I ate pizzas :).

EDIT: More Detail-- I have a day-wise record of user's activity. I want to show this detail as yearly view. In yearly view, listview should show total number of activities in that year. Also when user pinch zoom that year, it will take you to monthly view of that year and a ListView contains total user's activity in each month

Is there any way to do that? Any nudge would be appreciated.

user3265443
  • 535
  • 1
  • 8
  • 25
  • 1
    I think you should give up building nested list view and try to focus on putting your details on a non focus required view. You will most likely struggle a lot with the focusses with nested list views. For pinch zooming, http://stackoverflow.com/questions/5216658/pinch-zoom-for-custom-view/5305303#5305303 tells how to add a pinch zoom to any view. – Barışcan Kayaoğlu Apr 08 '14 at 13:44
  • @BarışcanKayaoğlu I also don't want to implement this as nested ListView. I have a day-wise record of user's activity. I want to show this detail as yearly view. In yearly view, listview should show total number of activities in that year. Also when user pinch zoom that year, it will take you to monthly view of that year and a ListView contains total user's activity in each month. Can you push me forward to right direction – user3265443 Apr 08 '14 at 14:27
  • Here's an example of expandable list view. I think it is what you're looking for. http://examples.javacodegeeks.com/android/core/ui/expandablelistview/android-expandablelistview-example/ – Barışcan Kayaoğlu Apr 08 '14 at 14:37

1 Answers1

1

Read up on Fragments: http://developer.android.com/guide/components/fragments.html

  • Have years and pizzas in ListFragments
  • create a ScaleGestureDetector
  • create an OnTouchListener and assign it to each view in getView() of your year adapter
  • pass touch events from the listener to the ScaleGestureDetector to detect pinches
  • replace fragment with appropriate pizza-filled one when it detects a proper pinch
Ivan Bartsov
  • 19,664
  • 7
  • 61
  • 59
  • Thanks. I think it will do part of my job. Also suggest me one more thing. In the year ListView, Along with the year, if I want to show images of different categories like pizzas, burger, noodles, etc. and my next view should recognize that on which image user has clicked. For example if user has clicked on burger image of that year, the next view should only show activity related to burger. Please suggest me a optimal way to do this. – user3265443 Apr 08 '14 at 17:16
  • Well, just display all the thumbnails items you need as part of your list view item's layout and assign each one of them an OnClickListener. (note that listview's own item clicks may not work if you use OnClickListeners for item's children, solution here: http://stackoverflow.com/questions/6703390/listview-setonitemclicklistener-not-working-by-adding-button). Then you pass the "what's been selected" info to the other fragment (here's how to do that http://stackoverflow.com/a/12739968/375929) – Ivan Bartsov Apr 08 '14 at 19:15