0

It's commonly used on the web, but in Android I can see only things like:

That's not enough. I already use a menus and two dropdowns (Spinners) on this screen for basic filters for my items list. I want to have additional options for filtering (basically, number of custom checkboxes) hidden by default, and accessible after tapping "More options" button - then the extra filters-checkboxes should appear below. And I'd like this options-area to be custom. It's a very common UI solution to webdev.

How can I achieve it in Android?

This picture shows what I mean - it's really simple:

enter image description here

Community
  • 1
  • 1
forsberg
  • 1,681
  • 1
  • 21
  • 27
  • 1
    show us what do you mean (ui design/image) – Mohammad Ersan Nov 16 '16 at 16:37
  • If you want fully customizable list you have to create your own Dialog/Screen with a RecyclerView in it. The recyclerview can benefit great from the ViewHolder pattern and supports it fully. You can have different ViewHolders for buttons, checkboxes, text, etc.. You can interact with them and afterwards add or remove items from the RecyclerView as "show less", "show more", "filters", etc..The thing is that there isn't ready solution for this, you have to implement it. The recyclerview is basically a ListView that recycles views automatically. – loshkin Nov 16 '16 at 16:41
  • Without any screenshot, it's really hard to make out what you are after. Maybe this will help: http://stackoverflow.com/questions/18913576/show-and-hide-drop-down-list-on-button-click – AlphaQ Nov 16 '16 at 16:54
  • I made a picture showing this UI element and how I imagine it. – forsberg Nov 17 '16 at 15:31

1 Answers1

0

Step #1: Design the layout complete with your options panel, basically to be what you want in the expanded state.

Step #2: Add android:visibility="gone" to whatever container class represents the options panel. Now, that panel will no longer be visible or take up space.

Step #3: Add a listener to your CheckBox, and use setVisibility() to change the visibility of the container class, per your business rules.

You can get fancier about this (e.g., animated show/hide of the panel), and there is probably a library that wraps up this pattern (check the Android Arsenal).

IOW, the approach that you would use in Android is very similar to what you would use in "webdev" or most other GUI toolkits.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491