i need to implement a list as shown in the screenshot below!
now, my question is, what BB component do you suggest to use?
i thought of a RichList, but there are not many possibilities to customize this component afaik.
the alternative would be a Table.
are there other ways to implement this? is it possible to customize a RichList in a way to make it look like the screenshot below?
Setup: BB Eclipse Plugin v1.3, SDK 6.0
Use a ListField. You will have to do your own painting to setup an individual row, but it will be the most efficient way of doing this.
I haven't studied the 6.0 SDK very much, but here is a possible solution for you list:
Each item in the list would be a HorizontalFieldManager. This HorizontalFieldManager would contain the image on the left(this would be a BitmapField) and a VerticalFieldManager. The VerticalField manager would contain 2 LabelFields. The first one for the first row that is bold, and the second one for the rows underneath.
Of course, the first HorizontalFieldManager would have to be FOCUSABLE. You can override the onFocus, onUnfocus and paint methods to handle the focused(selected)/unfocused(unselected) states of the field.
The list would be a VerticalFieldManager that contains custom HorizontalFieldManager elements, as I explained above.
I'm not saying that this is the best solution, but it's a solution and it works(I've done something similar for OS 4.5 - 5.0).
Related
I have a strange effect with a4j:repeat when using rich:toolbar in RichFaces. In my little example I just place a couple of icons on the toolbar. If I do it manually, they are all separately placed into <td>...</td>. But if let them generate by a list using a4j:repeat, they will all be placed together within one <td>...</td>.
The result of this is that those placed manually are more far from each other in the view. Those who were generated, stick together.
I believe the difference is, that the rich:toolbarGroup thinks of the a4j:repeat as one object, and of the manually placed ones as serveral objects.
I tried out with c:forEach as well, but I get exactly the same effect.
Does anyone know how to define the a4j:repeat objects as separate? Or if it is another problem, how to solve it?
If you're only worried about the spacing you can increase it by CSS.
<a4j:repeat> is not a good thing to use with the toolbar. If the icons you put in are supposed to have some sort of functionality attached to them you'd have a problem assigning it dynamically.
I'm using a Jface CheckboxTreeViewer and wondering if it's possible to provide only specific nodes with checkboxes. I'm afraid that there is no native support and won't be easy to implement. Maybe someone cann help me with this.
Cheers,
Phil
You can't do this with CheckboxTreeViewer.
You can use org.eclipse.jface.viewers.OwnerDrawLabelProvider to draw anything you like in a TreeViewer, so you could use that see http://www.vogella.com/articles/EclipseJFaceTableAdvanced/article.html
For just check boxes you could just use the images returned by a normal label provider to show nothing / checked / unchecked.
My target is to display an abbreviation list with two entries per line: the abbreviation and the corresponding long version. For a nice layout I used a GridPane because of the vertical alignment over all entries - it's nice to read.
But I also want to scroll to the clicked abbreviation and set the focus on it like in a ListView version of it.
For example the # on page links in good old HTML. Is there another javafx layout element I miss to achieve this?
I don't believe there is a provided control that will work for the specific scenario you are describing. However, I think one of these options might work for you...
Use the TableView control and add two columns for the information you want to show (one for the abbreviation and another for the long version). TableViews also have the scrollTo and setFocus functionality you're looking for. Here is a good resource to get you started with the Tableview control. You can also style the Tableview with CSS to look less like a table and more like a list if thats what your intention is.
The second option is to set a custom cell factory on your ListView that builds custom cells using HBoxes, VBoxes, Labels, etc. to achieve your desired look. You would also want to use the cell factory to populate each ListView cell with an object that contains both the abbreviated text and long version text. A couple good resources, 1, 2
Although I think both option will work fine, I would suggest option 1 since in option 2 you are sort of building a table type structure anyway. I hope this is helpful!
I am currently developing an Android app that is to be a counterpart to its sister iPhone prototype.
My task is to recreate the screen from a design mockup from the iPhone app in Android, as shown here:
What would be the best layouts / views to use for replicating this screen in an activity?
Thanks.
Your question does not clear some things up. Also, I disagree with Ted Hopp's answer. I believe he is assuming that the medications will be filled statically, or something like that.
By the looks of your app, I assume you will be filling stuff dynamically, probably with many medications at once, or no medication at all. By the arrows in the iPhone mock-up, I also assume you will want to perform actions depending on the medication selected.
All that said, I would use a ListView. My general concept (the one I'd probably use) would be like this:
You have your data source, and use a Loader/LoaderManager/etc. to fill that into a Cursor. I'd feed this cursor to a CursorAdapter (perhaps a SimpleCursorAdapter, which seems likely and easy by looking at that UI concept --- won't need to customize the adapter part itself). Finally, this adapter would be used in the ListView. This is fairly easy and won't take much code (the ListView-SimpleCursorAdapter-Cursor stuff, the data logic is certainly custom).
You can then manage each of your clicks using the proper ListView listeners, IIRC. And act accordingly depending on the item selected. I'm guessing that the user would, for example, startActivity to see a detail about each medication.
However, as I said, if you have a fixed number of medications (here says an experienced former leukemia patient here, so I always assume medications vary widely!), a single TableLayout would do, but I feel that's not the case.
Ah, and about the layout for each component/med, as I said, a simple layout would do. Probably a LinearLayout with horizontal orientation. Again, very simple to implement with a SimpleCursorAdapter.
There's a nice example of how to do this with a custom row view here. This is probably the cleanest way to go.
The closest built-in widget for this is a TableLayout. Take a look at the Hello Views tutorial project for an example of this in action. You might want to wrap it in a ScrollView.
The right approach is highly dependent on the requirements. As I see it, you have (at least) a few options:
TableLayout
ListView
Something custom
As David noted, the TableLayout is most appropriate if you have a fixed set of data, but you can make it work dynamically too simply by adding child views. The benefit of using the TableLayout is mainly a built-in implementation of columns, including dynamic column sizing based on contents. The down-side is the lack of built-in dynamic support, especially when working with large data sets.
A ListView is a better fit for dynamic and large data sets, but comes with the limitation of not supporting columns. Ted's link lets you simulate columns, but unlike TableLayout these columns have a fixed width (in percentage of the parent's width). The columns are not sized based on content. You could potentially try to do something to measure all the children, but it'd be tricky. It can also be mildly annoying to try to deal with headers in a ListView, though with a little searching you'll find plenty of resources to help you with this.
The third option is to roll your own AdapterView or AbsListView. Of course this involves a significant amount more work, but you could take a look at how TableLayout works and resize the columns based on the content. This would also get you support for adapters and all the benefits that come along with that. This is probably quite a bit of work though, especially resizing the columns based on content.
Consider whether your columns must resize to fit their content or not.
I've got a blocking problem with the sorting functionality of a JTable; this made stall the development of the spare time open source project for 4 months now. Hope to be pointed into the right direction here.
Context: I'm working on extending the functionality of the ps3mediaserver to add a media library with pms-mlx. The UI of the media server has been done using swing.
Problem: When clicking on a column header in the JTable, a seemingly random column gets sorted instead of the one having been clicked.
Current implementation: Here's the description of the different components and classes being used for the implementation:
ETable: As alternate row colours aren't supported by default in the JTable, I've switched to the ETable extending the JTable. Source comes from here
FileDisplayTable: This is the class creating the table. In the init() method, the sorting is being enabled with 'table.setAutoCreateRowSorter(true);'
FileDisplayTableCellRenderer: Exists to always align cell content on the left
FileDisplayTableColumnModel: Does some mapping between internal types and column names
FileDisplayTableAdapter: This class implements com.jgoodies.binding.adapter.AbstractTableAdapter to map the objects with the table columns.
Possible solutions:
Preferably, I'd like to keep the current implementation and figure out how to correct the sorting, but I doubt someone can help me out with that!? Additionally their are some bits of code I had to add because of strange behaviours; they're commented in the code
The alternate option would be to change the JTable for another control altogether. I've made some research but didn't find the solution I was hoping for. The constraints are that
it must be embeddable in a swing UI
preferably it should support data bindings
support alternate row colours
row sorting
At some point it will be possible to open an editing dialogue, where the content of the row has to be retrieved, can be edited and when saved the row has to be updated.
Before reworking the entire thing I'd like to be sure the component will be able to handle all I want to do with it.
I'm more used to create GUIs using .NET in Visual Studio. It's quite different and a lot more difficult to do the same with swing. Please show me I'm wrong :)
[edit] If someone is willing to reproduce the problem, either get the source or the binaries, launch the application, navigate to the media library tab. In the Genral section import some videos by adding some video files. Go to the library section, click on apply to refresh the list and try to sort the table.
It may be useful to know that JTable columns can be dragged by the user. As a result, the view (JTable or a subclass) and model (an implementation of TableModel) may have different column numbers. Similarly, a RowSorter may affect the order or number of rows in the view as compared to the model. The related conversion methods are mentioned in How to Use Tables: Sorting and Filtering. In particular: "When using a sorter, always remember to translate cell coordinates."
Addendum: As an alternative, consider org.netbeans.swing.etable.ETable or it's subclass org.netbeans.swing.outline.Outline, depicted here.