Baruch
Baruch

Reputation: 21508

Android hierarchical ListView

I am trying to implement a simple tree-like menu. I have a ListView as the root. Each item is a custom View that consists of an arrow icon at the right if it has a submenu and a checkbox taking up the rest of the row. This is all great.

Now here is what I want to do and can't figure out how (I am new to Android, but Googling didn't help me): If the user slides to the left on an item with an arrow, the whole list will slide out to the left and the corresponding submenu will slide in from the right. If the user slides to the right anywhere on the menu, the whole menu will slide out to the right and the parent menu will slide back in from the left. When you picture it it is really a simple concept.

My problem seems to be double:

  1. I can't figure out how to capture a sliding motion. I assume there is some onSlide event or some such, but I can't find it.
  2. I can't seem to attach events to the individual items. I tried just a simple toast with the onItemClickListener and couldn't get it to fire.

Any help or reference would be appreciated.

Upvotes: 1

Views: 1642

Answers (1)

Ridcully
Ridcully

Reputation: 23655

For the Sliding, check out the ViewPager class and the matching Adapter class, but generally what you describe sounds a lot like iOS and you should rather not try to duplicate a behaviour that's alien to Android users.

Upvotes: 1

Related Questions