I have 2 layout first one takes input and based on query show give output as shown in pic2.
However I am not able to introduce these layouts dynamically.
Each dynamic layout must have a unique id so that when "BOOK" is clicked specific ticket is booked.
http://i.stack.imgur.com/ez4DP.png
You should make the second layout not dynamic, but as a usual ListActivity of vertical LinearLayouts. And fill the ListActivity from the DB query.
The functionality you need is not unique at all, it only takes different DB table rows as a parameter. It is standard.
Related
Is it possible to create a layout for an application on android from fields in a database?
I have a table in the database that contains questions and I want to generate a "form" or "layout" depending on the data that is in that table.
For example, I have question one:
as we see in the table I have the column "tipo_pregunta" which is what it will say if it is an input, checkbox, textarea, etc.
I wanted to know if it is possible or if you know some guide from which I can learn.
Yes. Of course, you can generate layout dynamically.
Create layout(LinearLayout, RelativeLayout etc) object.
Iterate database result
Create a view on checking your "tipo_pregunta" value. like(TextView, Checkbox, RadioButton etc)
Add this created view in your layout object - layoutObj.add(viewObj);
Repeat steps 3 & 4 till your database result count.
I'm making an app where there's one main activity that is a Fragment. I basically have a few tabs and each tab/page layout I want a different layout. For one of them, I want to know if I can dynamically create a table of, say 20-ish rows with X amount of columns. Instead of having to manually create each row inside the layout .axml file.
The reason for wanting to dynamically create it is that I'm obtaining some data from online that I want to automatically put inside a table.
You will only need to create 1 layout for the item and it will be your item 'template' to inflate it into your ListView dynamically. Take a look at this RecyclerView example (which is the improved ListView)
I'm constructing a custom contact list with 5 required fields. It's a bit difficult to fit all 5 in a single row without looking like it's cluttering or doing nested rows which make it hard to distinguish the rows. Here are a couple of designs that I came up with (below). Is there a better way to organize the fields, such as expanding the row when selected to reveal more info, or simply make the row height bigger? Any suggestions?
Not so clear what your five fields are. Most important field(s) (e.g. name or contact number) should be at the top in bold style. The second row should contain less important fields, but you need to put enough spaces and style to distinguish them. You should also use ellipsize(...) attribute to contain them within the boundary. If it is important to show the whole string, you may even use third row for any field. Hope this helps.
I need to implement in my android app a component that displays data like in the image bellow:
How I can do this? Behavior(scrolling and other) of this table-component must be as a ListView. Now I have a two-level ListView where "List 1 label" and "List 2 label" are parent nodes. I want place them to left side. Maybe I must use TableLayout where in right column place a ListView?
you can use listview as a main item. on the other side in the getview() method of adapter you can create a dynamic layout depending on the number of items to add to the right side. by going dynamic at runtime depending on the requirement you will be able to generate the ui and place it as a single item. or the other approach you are using is also correct i think, but in that case number of table rows to inflate would get fixed if you are not going for dynamic ui.
I want to create a UI as shown in the below link:
http://i53.tinypic.com/sxksx5.jpg
According to me there can be the following approaches to do it.
There are two tables in this image. The above table should be made in the following way:
One row with two textview in one xml file. Now Inflate this UI using LayoutInflater. Draw It using a loop and set the text according to requirement.
The below table should be made in the following way:
How to make a dynamic table layout using XML
see the above link where It is advised that the 2nd table should be made using the listview.
Now I am confused that this can be made using gridvew, tablelayout, listview. Which one I should prefer and why? In my previous projects I have made this kind of UI almost in the coding. But I believe that a little change in the UI will require lot of change in the code. So I want to make the current UI using the xml. But dont know what approach would be best.
I'd suggest using a ListView. Subclass it and overload the getItem() method to render each column of the table row. You can then easily bind the listview to your data sources. you'll need to create an XML layout resource to describe a row of the table.
To show one table above another, put the listviews inside a RelativeLayout and specify attributes to position them relative to each other.
http://developer.android.com/reference/android/widget/ListView.html
http://developer.android.com/resources/tutorials/views/hello-relativelayout.html