Android UI requirement - android-widget

I have UI requirement shown below:
|------------------------|
|Header-1 |
| Checkbox1[] |
| Checkbox2[] |
| Checkbox3[] |
|------------------------|
|Header-2 |
| Checkbox1 [] |
| Checkbox2 [] |
| Checkbox3 [] |
and so on clicking below button.
BUTTON -> clicking on this button on bottom will create header and 3 checkbox everytime. How can i achieve this? This is very urgent. I can not take these in XML laypout as these need to be added dynamically on runtime.
If possible, Please provide any sample code and guide me.
Thanks,
Rachana

You should create a listView containing rows defined by a layout having :
a linear layout containing a textView with Header-1 (and so on) as text
another linearLayout containing three checkboxes.
You will create an arrayAdapter with a list of strings representing different values for Header-1 (I guess checkboxes will have same values all the time).
Adding a click listener (onClickListener) on your button. This listener will add an item to the arrayList used by the adapter to add new items in /remove items from your listview when your arrayList is modified (calling notifyDataSetChanged()) to refresh the listView.

Related

Selecting multiple rows on CheckboxTreeViewer without using the 'ctrl' button

I have created a checkboxtreeviewer using the JFace library. I have created the tree viewer as below
Tree tree = new Tree(parent,SWT.CHECK | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
CheckboxTreeViewer checkboxTreeViewer = new CheckboxTreeViewer(tree);
The SWT.MULTI allows me to select(highlight) multiple rows of the tree using the 'CTRL key.
Is there a way we can select multiple rows without using the ctrl key. One way i know of is using the setSelection() method, which cannot be used since that causes a flickering effect when the user goes from one row to another , the Tree.java would deselect all the existing rows and then highlight the rows that are called in the setSelection method.
I feel the code here is causing a deselect to all rows and then a select on the row selected by the user.
You can turn off redrawing of the tree until you have finished setting the selection, this should reduce flickering:
checkboxTreeViewer.getControl().setRedraw(false);
checkboxTreeViewer.setSelection(....);
checkboxTreeViewer.getControl().setRedraw(true);

grouped list view in gtk

Is there a way to achieve a view in following screenshot by Gtk?
I have tried treeview, but it doesn't automatically filtered out the group.
KDELibs equivalent is KCategorizedView.
Edit:
My use case it like:
for example like the screen shot, if I type Mythology, AOE and AOE III will not be shown, since there is no match under that group.
If I try to use treeview, the parent node not cannot be easily filtered, since the filtermodel cannot easily depends on the filtered result.
you can use a GtkTreeView with a GtkTreeStore, but there is no stock widget that has the appearance of the KDE widget.
alternatively, you can have different GtkTreeView instances, each inside a GtkFrame and each using a GtkTreeModelFilter to apply a filter to the same GtkListStore or GtkTreeStore, so that you can keep that data inside a single storage.
the layout would look like:
GtkBox
+---- GtkFrame
| +---- GtkTreeView
|
+---- GtkFrame
| +---- GtkTreeView
|
+---- GtkFrame
| +---- GtkTreeView
|
...
the GtkTreeModelFilter can be set to filter all rows inside the source GtkListStore or GtkTreeStore that match the "category" you want.

How to achieve an advanced table view header

I have a grouped UITableView. Now unlike the default table view header my header should be next to the individual cells:
Standard:
[Header Cell]
[Item 1]
[Item 2]
What I need
+-------+----------------+
| | Item 1a |
| h1 +----------------+
| | Item 1b |
+ - - - +----------------+
| Item 1c |
+------------------------+
| | Item 2a |
| h2 +----------------+
| | Item 2b |
+------------------------+
| | Item 3a |
| h3 +----------------+
| | -placeholder- |
+-------+----------------+
Some remarks:
Group H1 has three items
Group H2 has two items
Group H3 has just one item (I have to insert a placeholder cell so that the header cell can have the full height of two item-cells
When the user scrolls the list then the header should be pushed upwards that the two header-cells don't overlap.
The challenge here is the height of the header cell:
If I set the height to 0 and uncheck clip subviews then that header cell is shown but does not get pushed away at the correct position.
If I set the height of the header cell to the visual height then there is an empty space of that height across the whole width of the table which I don't want...
Update 1: I just realized that apple uses such a list for the search (grouped by messages, mails, contacts, calenders etc.). So my question basically is how can I tweak UITableView in order to behave like the grouped search results... :-)
(source: mshcdn.com)
Update: I created a project on github, which does exactly this. I have extracted all the relevant code for the behaviour into two classes (BBFloatingHeaderViewController & BBFloatingHeaderCell). There is also an example project. I hope this is useful for others :-)
Here's the project: besi/FloatingTableViewHeader
This is an excerpt from the readme:
Floating UITableView headers
These classes aim to copy the behaviour found in iOS built-in Spotlight search, where the search results are grouped by category and the icon of the respective category floats on the left side of the search results.
Setup
Check out the example project so see how to setup the classes.
Add the .m + .h files of BBFloatingHeaderViewController and BBFloatingHeaderCell to your project.
Create a TableView and set the Class of the ViewController to your subclass of BBFloatingHeaderViewController
Create the header cell in IB and set its class to your subclass of BBFloatingHeaderCell
Make sure that your floating header view is the topmost view in the BBFloatingHeaderCell's view hierarchy.
The result
Floating Headers http://i.minus.com/jyea3I5qbUdoQ.png

TextCell and TextInputCell in GWT CellTable Header

I need a search box on the header of the GWT celltable.
I want both the Name of the header as well as the textbox in the header of the cell table.
|Header 1 | Header 2 |
|SEARCHBOX | SEARCHBOX|
| ROW 1
| ROW 2
I can have any one textCell or TextInputCell in the header. But i'm not able to have both in the header.
can you help me plssss?
Thanks in advance.
Gnik.
I have implemented something like that however I run into a refresh problem.
But if you don't refresh the CellTable after each keystroke there shouldn't be an issue.
For implementation details check out this thread
Basically you have to implement a custom AbstractCell (alternatively you could extend the TextinputCell and override the render method to output the header).

Table View inside of View Controller

All,
I have a regular view controller with several buttons on it, but when one of the buttons is pressed it retrieves information that I want to throw right above the buttons.
For the sake of this, imagine a blank view controller with one button at the bottom. When this button is called, it gets X number of items that need to be listed (and available for selection) right above the button.
I tried illustrating it for you here. :X lol. There are three items viewed, but say that 10 items came back - I need to be able to scroll through the list as well.
The question is this: how do I add a scrolling view (possibly table view) inside of my view controller so that this works as explained?
__________________
| |
| |
| item 1 |
| |
| item 2 |
| |
| item 3 |
| |
| |
| (button) |
| |
|________________|
Thanks
You simply add the UITableView as a subview of the view controller and implement the UITableViewDataSource and UITableViewDelegate protocols as usual.
It's not harder than that. Try it and if you get any problems ask another question.
Do you have Scrolling Enabled on Table View ?
I don't think so you need to do anything. TableView will take care of it.