I am learning android development ,I want to create dynamic table rows .I don't know how to create .I want to create two table .One should static and Another should be dynamic .
I referred in internet and i saw table layout , recycler view and I don't know which is best way to do it.Please someone guid me.
I want to create a tables like this
I have tried like this only
You cannot simply create table and rows as simple as in webpages. you have to use TableLayout,TableRow and textview(for rendering text inside of it).
create no of textviews as cell and add it to TableRow(android layout) then add the tablerow and add it to TableLayout and then add tablelayout to root layout. On dynamic insertation invalidate the view to see changes
Related
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 want to create a table in my android application, in which the data will be added on the run time i.e. no. of columns and rows would be decided on the base of user input and user can later add more columns or rows in the Table.
So, using Table Layout of Android is not solving my purpose so far. And I created the table using Linear Layouts under other linear layout, but as I add any row or column I have to create the whole view again which is making the application very slow. So, what can be other approaches or how can I improve the functionality of my application.
Thanks in Adavance.
I am using a table View in my xml. Currently all the rows look the same(shown as the first table), so I want the header to be different to the following rows, such as the 1st table in the picture
I tried to set the first row as buttons but they look weird, does anyone got a idea? thanks so much for the help
this post Android TableLayout Header row may be helpful to you
they are using Tables inside tables
OR
see my answer in this post. android create textViews in tableRows programmitcally
this question author is using fixed textviews as header in xml. here you can control the textview attributes to look them like headers
then he is trying to add the table contents via program
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
I want to create a dynamic table.My problem is this that I want to use check boxes and buttons in row of table and the buttons and checkbox are custom one.I have created those using selector.xml files.And I am not getting how can I create and add my rows dynamically to my TableLayout.Plz Help
I found the solution.
Here.