How to create an Accordion Menu? - java

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

Related

Looking for a combobox but not an Android spinner

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

Equivalent of Android radio buttons with no popup and one selectable choice?

I want to create something similar to a listpreference menu item with a single selectable option out of four options. The problem is that descriptions are necessary for each selectable option and they are rather long. Shortening descriptions further isn't an option.
The Android app I'm working on currently uses a custom method for displaying a menu item's summary field. The summary calls an int which points to a string reference stored in a different file that displays a string. I tried using %s as the summary to update the summary with my selected option but that literally returned "%s". I don't think the current method supports dynamically loading summaries.
My next idea is to create a submenu with four selectable choices (maybe checkboxes?) and only allow one to be chosen. I think this is essentially a listpreference menu item but allows more space for separated descriptions. Is there a preferred way to accomplish this? I'm trying to avoid re-writing the original custom method for displaying descriptions as it works well for the rest of the app's menu needs.
EDIT 1: An image will help explain what I want. See Android sample settings menu. I want to create a section similar to the "embedded frame buffer" section in a submenu except only one of the three options are selectable. This approach will allow me to have more room for separated, long descriptions. Perhaps I'm looking for radio buttons with no popup and one selectable choice? Is this a thing in Java?
Not sure if I understand the question correctly but instead of a list of checkboxes where only one checkbox is checkable use a RadioGroup with Radiobuttons. You can have multiple RadioButtons which you add to a RadioGroup and then only one RadioButton can be selected.

"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

find and select in JTable

Hi am creating an application in which I am using JTable to listing of file or folder names.
My question is:
How can I find and Search a Particular file or folder in JTable like in Windows.
In windows directory listing when we press any key then we can see that file or folder start with that character is selected and if we again press same key then next file/folder is selected with start with that character.
If you can use 3th party code, I would suggest to take a look at the SwingX project. Their JXTable, JXTree, JXList and some other classes provide an implementation of the Searchable interface, which makes creating a search widget a breeze.
And if that is even too difficult, they provide out-of-the-box a JXFindPanel which provides a UI to search a Searchable
If you can (and you're willing to) use third party UI components, the Open Source JIDE Common Layer offers a few nice components: e.g. you might like FolderChooser which has an automatic find-as-you-type functionality.
Here's the link: JIDE Common Layer. If you click the "RUN IT" button you can see a sample via Java Web Start.
I've used many JIDE components (only the open source ones) in my projects and avoided reinventing the wheel many times.
Hope this might help you.
You want an action happen when a key is typed ?
-> add a keyListener to your table
You want to know which row is valid
-> query your datamodel connected to your jtable
You want a selected row to change ?
-> in the keytyped implementation of your listener change the selection
table.getSelectionModel().setSelectionInterval(1,1);
Since I don't know something about how did you implement your code logics, JTable implemented Sorting and Filtering
but you describtions talking about JTreeTable
I would consider writing a custom TableCellRenderer, responsible for highlighting any matching letters in the String being rendered. When someone updates the search text field the simplest approach is going to then be to repaint the entire JTable to show the updated "match state" of the table cells.

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