I have some json collection got from rest api, it defines various parameter types, like:
spinner with values collection (of string or some class objects with some fields)
date time field with date value
text edit field
set of check boxes (check box defined by id, name - caption, state checked/unchecked)
set of radio buttons
Each parameter is also named.
What I need: visualise list of items (each item will be one from types described above), let user to adjust values for each of them, retrieve collection (in the same json format) and post modified json to server.
Firs approach I've considered is to dynamically add controls to my layout inside scroll view, corresponding to item type. But I feel this is not good approach, maybe better to user RecyclerView and custom list.
Do you have any ideas how to construct list like that? Afaik Android RecyclerView assumes each list item to have the same layout, is it possible to get what I need?
This is something similar to what I had worked on. You'll need to create different viewholders and create types based on type of input required for each item in the collection.
In order to get the latest values user has entered, have them stored in the model class dedicated for the json response, map them and send them back to server.
Check this out :
https://guides.codepath.com/android/Heterogenous-Layouts-inside-RecyclerView
I had used TextWatcher to intercept changes made by user to edittext, checkchangelistener for radiobuttons, DateTimePicker with a textview to show date and time.
Use of textwatcher in edittext :
How to get the Edit text position from Recycler View adapter using Text Watcher in android
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).
What I want to create
I want to create a list where each item in that list is an data table like below: The user needs te be able to sort items in the data table and needs to be able to sort the data tables itself.
Each table is going to represent a client and each item in that table is an order. The user will then collect the orders, if he collected an order the order wil dissapear but the user is also able to bring them back.
What I tried
I tried to put a Recyclerview inside a Recyclerview but this caused unitended side effects and bugs, also I read online that it is basically a bad practice. My initial intention was to use a recylcerview with a sortedlist.
I did some searching online and a lot of people recommended using categories between items so that you only need one list. But because I have data tables (CardViews) that can be independent sorted this isn't an option.
If anyone want to give me a nudge in the right direction, I would be really thankful.
What you can do you can use recycler view and in custom row check box with 8 text views and when position is 0 inflate categories like fat, calcium etc and after that position populate data and if you want next button which shows next items in list use fragments or pagination that should do the trick and you can achieve this using single recycler view. You can also use header to show categories.
I have a list of items that are pulled from a database, it combines the various fields with a rs.getString method to create a longer string of items, this is done in an action button method.
I would like to be able to click on an item in this list and have one of the fields display as text in a textbox, so this needs to be done through the list selection event method where I instruct the program to set the text to my desired value.
My problem is, I am not sure of the logic to follow in order to specify how to retrieve that fields information that will be corresponding to the item that is selected in the list, can you give me any ideas?
Rather the combining the fields into a single String, create a POJO (Plain Old Java Object), which provides getters (and possible setters) for the fields you want and these objects to the ListModel
Use a ListCellRenderer to customise the way which the JList renders the POJO the way you want to. See Writing a Custom Cell Renderer for more details.
When the user selects an item from the list, use JList#getSelectedValue and cast to the same class as your POJO. You can now use the POJO's getters to extract the properties you want to display.
The idea is to generate a self contained unit of work, which, based on what you want to do, you can customise how the object is displayed.
This concept is a corner stone to the separation of data (model) and the UI (view) behind the Model-View-Controller paradigm and OOP generally...
I am attempting to create a list view which displays different data based on a selection from an a spinner.
My list view is implemented via a base adapter which works fine.
My data is stored in an array list of objects which each contains fields that store individual data and based on the selection from the spinner filters the data stored in the array list and displays it on the list view.
But my question is how can I clear a list view content without clearing its underlying data (stored in the array list) and calling notifyDataSetChanged? I want to be able to preserve the data stored so if the user goes back to a previous selection, the data is still present.
Thank you for your time in reading this.
As your data is stored into an ArrayList, you can simply use:
listView.setAdapter(null);
It will remove the adapter of your ListView, and so, remove all the items displayed.
The data will still be in your ArrayList so if you want to re-display this ListView, you just have to recreate your Adapter and set it again. You can even create a global instance of your BaseAdapter so you only have to create it once.
You could just pass another ArrayList to the adapter with the new data to show inside the ListView.
Or, you could create two ArrayList inside the Adapter, one named original which contains the original elements of the ListView and another currentElements which will be the real ArrayList to show changed as you want. With some custom methods, you can choose to switch between the two versions of the ArrayList.
It's could be the same concept of an Adapter which implement a Filter.
Anyway if i understand your problem, you want to change the content of a ListView based on the selection. Well, in this case i would send another ArrayList to show.
Create a list of adapters, one adapter for each selection. Then simply switch to a different adapter when the selection is changed with listView.setAdapter(adapter)
I'm trying to convert a drop down box widget into a SuggestionBox because the current drop down menu has 100+ choices. It seems like you can only add String suggestions to a SuggestOracle though. I need to be able to add a custom object that contains both a description and an ID that matches the record to the database though. Would I have to extend the SuggestOracle class?
Yes as i know you can not use pair of values i.e Id and Value. You have to add your strings in suggestion box perhaps you can use different solution other then suggestion box i.e. Create a List of values popup. And add as many fields as you like. display your data in flex table with pagination. update your form with the selected row by using selecition handler. for reference how to use FlexTable and handle events please see able Single Row Click Event
SuggestOracle is the parent class of MultiWordSuggestOracle which you are already yousing.
public class MultiWordSuggestOracle extends SuggestOracle
see MultiWordSuggestOracle