How can I reference a position within a Set? Like with an array: array[5];
I am developing an android soundboard that has a favorites tab. The favorites tab uses a listview . When a user adds a favorite, the text of the button is added to the set. Now I have setup a contextmenu for the list view to allow the user to delete an item by long pressing, and pushing delete. The context menu passes the position of the list view that triggered the context menu and I am trying to delete that position.
You cannot. Sets have no notion of order, but concrete implementations may.
However, all sets implement toArray(), and
If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.
What's your underlying data structure?
You can't - a Set does not have indexes for its elements. You have two options, depending on your requirements:
use a SetUniqueList from commons-collections, if you want the properties of Set in a List
use Iterator (and a foreach loop) if you want to iterate the Set
Related
I have a viewEntryCollection in SSJS from a sorted view displayed in a repeat which is displaying a table on the web page
I now want the viewEntrycollection do be sorted as any of the other sortable columns in the view. (i.e the user click on a columnn in the table and set a viewScope variable that I can use when I get the entrycollection)
I do not want to resort the entrycollection programmatically and I do not want to update the view design. I just want to change which column the collection use for sorting.
Preferably the same way a viewPanel can be set to be resorted based on specified sorted column.
any ideas?
If you have a NotesViewEntryCollection you retrieved that from a NotesView object. To sort that collection, you need to resort the view object after you've opened it using the resortView("colName", sortAsc); method.
That will only work if you enabled the 'click to sort column' option for the column you want to sort on.
If you need more control over how view data is handled (including sorting), have a look at the Domino JNA project and this blog post (disclaimer: I wrote that post).
i have a jComboBox, it happens that i may have the same value for more than on item. In this case, when selecting one of them, , the selection goes always to the first item on the list. Right after the click.
Have someone experienced that?Have some solution for that, so the selection doesn't change?
When i select:
http://i.stack.imgur.com/IjlYM.png
Checking again:
http://i.stack.imgur.com/c1lcQ.png
it happens that i may have the same value for more than on item.
Then it sounds like you are adding a custom object to the combo box.
If it displays the same value but is a different item, then you need to implement the equals() method in your Object so the proper Object can be selected.
If you need more help then post a proper SSCCE that demonstrates the problem because we don't have enough information to keep guessing what you might be doing.
A JComboBox always tries to synchronize what is selected in the lists with what is shown in the display field. To do that, it searches the list sequentially for a match of the editor field. So it will always find the first one if there are identical items in the list. Thus you can't just use String objects if there is a possibility for identical Strings in the list. You need to do what #camickr said and use a custom object that has some way to distinguish between two objects whose toString() method returns the same thing (assuming you use the default model and editor).
I have a series of buttons that I would like the user to press in order to show a different list in the list view. Say, button one brings up list one. User adds a few items to list one and then presses button two to open list two; user then adds a few items to that list.
How would I go about having multiple list that share a single list view? Also, how would I have the data of one list be saved so when the user switches lists... they can switch back to the original and have their items still presented in the list?
Thank you!
I guess what you are looking for is ExpandableListView
here is an example too
You could have multiple lists stored in some type of array. A list could be used for each list, and then when you are setting the listview's adapter, pass the current list object. Of course, after each item is added during the adding process(when user is adding items) you would need to add the items to the list, and then reset the listview. And as long as you kept the lists in context the entire time they would not be GarbageCollected. Once the user is done with the lists, you would need to save the lists somehow, unless this is just a temporary context where everytime you revisit the page it shows the default value for the lists.
I would like to persist list item selection like it is on first picture(Circle Fragment Example), so when list item is selected it should stay marked as "selected". What I have is two different project I found on net. On first picture is behavior I want to achieve.
On second image(Fragment Basics) you can see that list item that has been selected do not persist "selected" state. What I don't understand is next:
In both case function that is being called is setItemChecked(position,true) but seems like different behavior is applied.
Check if on your second project the choice mode of your list view is set to choice_mode_single
And if the resource parameter of the ArrayAdapter is android.R.layout.simple_list_item_activated_1
I have a TableViewer where the values in one column should typically come from a dynamic list.
I'm currently using org.eclipse.jface.viewers.ComboBoxCellEditor , which is actually a Select-List: it stores the index of the selected value. If I change the underlying list (calling setItems(String[]), it's clumsy to keep the previous selected value... (specially if it's not included in the list anymore!) What I'd wish is actually a cell editor that stores, not the index from the list, but the string (perhaps letting the user edit it freely, perhaps not), where the list is just used as a suggestion at input time - like a "combobox" was supposed to work in the good old days... Is this possible?
I would suggest you to have your CellEditor to mimic the behavior that you are looking for. Extend ComboBoxViewerCellEditor and override doGetValue() method. Add modify listener on Combo control and also filter (which filters list items based on input text) to comboviewer.
You should look at :
org.eclipse.wst.xml.ui.internal.properties.StringComboBoxCellEditor This class comes from WTP project; It's an extended ComboBoxCellEditor that selects and returns Strings.
codemirror.eclipse.ui.xquery.viewers.StringComboBoxCellEditor It's the copy/paste of WTP StringComboBoxCellEditor; it adds the capability to add the item in the combo when it is not found.