1

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

Nayn
  • 3,594
  • 8
  • 38
  • 48

2 Answers2

2

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.

karn
  • 5,963
  • 3
  • 22
  • 29
  • 2
    But what if the text length in header is less/more than the length of text in the rows ??? that will disturb it again if i m not wrong – samir Sep 11 '12 at 07:53
  • large text length will always create problem no matter what layout you use..for that you should use multi-lines and marquee property. – karn Sep 12 '12 at 17:51
0

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

Nayn
  • 3,594
  • 8
  • 38
  • 48
  • That's precisely the problem I have. By using layout_weight instead of widths, its easy to match the header columns to the layout columns but the sizing isn't dynamic to the text anymore. – mikebabcock Mar 22 '13 at 17:55