how to customize the header in table view_android, (picture is shown) - android

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

Related

Best way to dynamically add rows to TableLayout in Android

I am new to developing in Android, so below are some really basic questions, but I feel like populating a table in Android is not straightforward.
I have a list of objects and would like to add each object to a row in my TableView.
Also I would like to have a fixed header with fixed columns.
Each header cell should have the same width as all the other row cells in that same column.
Question 1: How do I add a column? By adding multiple TextViews to a TableRow and foreseeing borders myself? Isn't that done automatically?
Question 2: If I add a new TableRow dynamically to the TableLayout and add the same amount of columns as the header (aka new TextViews?), will these automatically have the same width as the header's column?
Question 3: Is there an easy how-to that would anwser my questions? I've been googling for a while now and I don't seem to find any simple tutorial.
You should use RecyclerView with GridLayoutManager

Creating a Dynamic Table?

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

How to create a table above other list

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

Android DB List Adapters: multiple columns, aligned?

Ok I can't find a sample anywhere.
I've done the notepad tutorial on Google's Android site, but I would like to know how to add more fields to the list, in columns. At the moment I can add the columns no problem, but they're not aligned like you would a normal table on the layout:
john smith
heinrich cilliers
will peck
I would like the first names and last names aligned proportionately, as you would in an html table.
It works if I use a constant value for the layout_width parameter (100dip etc), but I would prefer to use a relative percentage. However it's becoming clear that each row is on it's own, and does not know how to alighn itself with the row above.
Any pointers?
UPDATE: I've reached an experienced Android developer which advised me to use WeightSum, which brings me closer, but vertical alignment is stil not happening:
I think therefor you have to extend the ListAdapter.
http://developer.android.com/reference/android/app/ListActivity.html

How to add header to Multicolumn ListView

I couldn't find this question already being asked on this forum.
I am little short on time to search anymore.
I have a multi-column ListView with three TextViews.
I need to have header for each of the column. I am using Android 1.5 SDK.
Can somebody help me here. I can't use addHeaderView since it adds just one view which would contain just one title string.
Thanks
Nayn
One easy solution to this will be to use same layout params for the header as you are using for the list item.Eg:
If you have three TextViews, suppose 1st one is right aligned, 2nd one is to the left of this and 3rd one is to the left of second one. Now for the header as you have separate headers for each column, you can use the same layout params for the three column headers i.e 1st one is right aligned, 2nd one is to the left of this and 3rd one is to the left of second one.
This is just an eg. the basic idea is to keep layout params(relative position,margins,padding,etc) same for both of them.
I tried this and it works for me.
I added a separate table above the list view which has all the columns listed. This solves my problem. Just that data is not aligned properly with the columns. I'll think about it later

Categories

Resources