Looking for a combobox but not an Android spinner - java

I'm trying to get the same item as Window's combobox in Android java. I realize there's a spinner but what I need is to display a scrollable list of items that the user can simply select one or more. The spinner is nice, but it's a totally different beast.
Is there an equivalent? Because otherwise I guess I would have to create a section of text items, that I would have to build my own scroll function as well as selection. Hoping to avoid all that.
Thanks.

You're going to have to write your own, or find a library. There is no builtin equivalent. Luckily it should be easy, you basically just want a recycler view where the adapter keeps track of what items you've clicked on. That will take care of the scrolling, and the display simplifies to a normal list adapter.

Import third-party library just for little feature is unnecessary, you could try change spinnerMode to dialog, then the spinner is scrollable.
Edited:
sorry, I noticed that you need select multiple items, my answer is not suitable. You could create a custom widget.

The easiest solution is using library. There a alot library you can use for that problem. Here is the some library you can used:
https://github.com/prsidhu/MultiSelectSpinner
https://github.com/pratikbutani/MultiSelectSpinner
Or you can follow this tutorial
https://trinitytuts.com/tips/multiselect-spinner-item-in-android/
Hope it help

Related

How to check if a View reach the end of ViewGroup

I have been working on an app that adds views programmatically to a linear layout.
The problem is if I add too many views it will go off the screen.
I would like to know how to check if a certain child has hit the end of the same view group so I could add it into another layout (a linear layout below the first one) before it "flows" and go off the screen. How might I accomplish this?
Rather than reinvent the wheel yourself, I suggest that you check out the FlexboxLayout project by Google: https://github.com/google/flexbox-layout
A FlexboxLayout will automatically give you the behavior you're describing, plus the potential for much more.
Well, there are a good number of ways you could implement this in android other than going through this hustle. What ever you are trying to do at the moment may fall under one of the following cases.
Creating views programmatically most likely means you have a dynamic data set probably from an external source.
Your dataset is limited or static but just more than the average screen can display.
if any of the above apple then you are better off using a ListView or RecyclerView (Recommended). That way your data is full displayed as a scroll-able list and you don't have to worry about some items or views not showing or going of the screen. This can range from simple string list to complex nested views.
This will be very efficient as it will automatically handle optimization and usage of memory as well as performance.

How to create an Accordion Menu?

I want to create Menu like this. Tap on any Item it will open Submenu with Items
I don't think there exists a library which will allow you to do this. (I may be wrong).
But according to me the best possible way to achieve this would be to use two tableViews placed next to each other and updating the the data for the second tableView on didSelectRow of the first tableView. You would have manage a few complexities but it is achievable.
If you only have 2 level of details in your menu, you could also use one tableView, show the 1st level elements in the section header, and create rows on section header click (using a button or tap) for the second level elements.
Edit:
My answer mentions some iOS naming conventions. Because it was originally asked for iOS with tag iOS and swift. I decided not change the original answer because the core concept of achieving this should be similar on both platforms.
Anyways, I think you can still do same stuff for android, just use list view where I mentioned tableView

"expandable" menu to the right - Android \ Java

I know it's not a legitimate question but I'm searching an example to this menu for Android\Java about 2.5 hours and I'm lost. Please just give me a link or write me its name so I can google it, find examples and implement it by myself.
I just saw that many people use sliding menu or dropdown menu but it's different than what I want I guess.
(source: smashingmagazine.com)
Each of those is a spinner, so I thought it might be called an expandable spinner, and got some hits for what you're trying to do : expandable-spinner : How to implement expandable spinner entry in Android
Another term for it might be "multi-level spinner" for which there are more hits similar to what you want. Best practices for implementing a multi-level Option Menu on Android?
I'm not sure this is the best approach for a menu, though. Would you consider something like this instead: https://github.com/pratikbutani/MultiSelectSpinner

How can we use Linear layout in place of a ListView

Now a days i have a requirement like i need to create a list with fixed 5(max) items or 2(min) items. I am considering the way not to implement listView but trying to implement Linear layout with dynamically added childView. The childitems are editable & clickable textViews with so i need to implement Click Listeners as well. I found many ways to handle kind of requirement but i am still confused which is the best approach so i could assure about the application performance and no backlogs. Can anybody suggest what is the best approach.
If you only need 5 items,I would use the simplest way, LinearLayout and add childs. Use a "for loop" for adding your childs and implements onClickListeners.

How to make an expandable list with Java Swing

I need to make an expandable list using java swing. I will attempt to demonstrate:
Unexpanded:
>[Expand me!]
>[And me!]
Expanded:
|[Expand me!]
>[Expand us too!]
>[Expand us too!]
>[Expand us too!]
>[And me!]
So, when you click on the "Expand me" portion of the list, another lists will drop down, possibly containing more expandable lists. If you were to click on it again, it's "sub-lists" would then retract. Pretty basic. And, as you can see, I am not looking for JComboBox, and I do not think JList can do this. If someone were to point me in the right direction, or give some programming examples, I would be grateful.
Thanks,
MirroredFate
How about using a JTree.
A control that displays a set of hierarchical data as an outline.
You can try using a JTable and put a button in the first column. When the button is clicked you add more data in the rows in between.
update
Something like this:
Or this
I think the first uses a JTree but that the idea.
BTW these two belong to JIDE Soft, check if it is feasible for you to buy a license:
http://www.jidesoft.com/products/grids.htm
Is not trivial to roll you own but is not impossible either.
check for TreeTable or one example or Outline, but with notice, that on official Java (SnOracle) pages any progress died ...,

Categories

Resources