1

I want to display categories-subcategories using list view (sort of breadcrumb menu). But I don't know where to start?

Here is the requirement

The first screen should show a list of categories. When user click(touch) one of the items, it should show the user another sub-category menu. Again when user click(touch) on of the sub categories item, it should show another subcategories view.

The sub categories hierarchy is not fixed. E.g. Category A might have 5 level of subcategory, where as category B will have just 3 and category c Might have 6 sub catgory and so on.

Here is data hierarchy(just for example)

Category A
    Sub Category    1
        Sub-Category-Sub 1
        Sub-Category-Sub 2
        Sub-Category-Sub 3

    Sub Category    2
        Sub-Category-Sub 1
        Sub-Category-Sub 2
        Sub-Category-Sub 3


Category B
    Sub Category    1
    Sub Category    2
        Sub-Category-Sub 1
        Sub-Category-Sub 2
        Sub-Category-Sub 3
            Sub-Category-Sub 1
            Sub-Category-Sub 2

My question is how i can implement this kind of behavior in android using listiview? I have seen this kind of navigation in homedeopot app.. Also best buy app has same functionaltiy. In IOS, apple store app has similar functionality(just for example)

So in one sentence my question would be

How can I use list view for navigation like the one in home deopt app or best buy app or any other app which display first category and on clicking on the category it will load another list view ?

Android ListView Navigation

EDIT

Finally I found my answer. First of all the solution I asked is a wrong approach for this problem. Instead of having multiple views, what we can do is set the adapter dynamically for the listview, and animate the list view from left to right.

For animation see following url.

View animation right to left android

Community
  • 1
  • 1

1 Answers1

0

Use a custom Adapter and have boolean collapsed in item model. Work on the value of collapsed in getView, getCount, etc.

I guess someone already made such Adapter / ListView compilation, so you may want to search for such a library on GitHub.

MaciejGórski
  • 22,187
  • 7
  • 70
  • 94