HorizontalScrollView Column Width Help

WiLey2000

Member
Licensed User
Longtime User
Hi All!

Been awhile since posting.

I have a example & picture attached below.
What i would like to do is change the row height of the second row and leave the headers as they are.
This scrollview is displaying a week of data, Date in header & job description in second row.
I would like to make the second row height 3 time the header height.
Is this possable?

Also is it possable to formate the headers for date formats?
ex. Aug-12 (short month-short-year) First header column.
ex. Mon-25 (short day name-day)

Thank for Helping!

John
 

Attachments

  • HScrollViewHelp.zip
    10.1 KB · Views: 281
  • display.png
    37.4 KB · Views: 427

klaus

Expert
Licensed User
Longtime User
The original Table class admits the same height for the header and the rows.
In the attached project I modified the Table class with two differnt heights.
You can change the values in the class code.
HeaderHeight = 30dip
RowHeight = 60dip


Best regards.
 

Attachments

  • HScrollViewHelp1.zip
    10 KB · Views: 289
Upvote 0

WiLey2000

Member
Licensed User
Longtime User
Thanks klaus, worked like a charm! :icon_clap:

Also is it possable to formate the headers for date formats?
ex. Aug (short month) First Header Column Only.
ex. Mon-25 (short day name-day) The remaining 7 Columns

Thanks Again!

John
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Yes.
In the attached project I added following routines in the Table class:
- GetHeaderValues
- SetHeaderValues
- changed NumberOfColumns from Private to Public

The date format change is done in the Main activity.
In my first test I modified the date in the Table class but then it would have been specific to your application.
So I added the routines mentioned above to get and set the header values from outsides.

Best regards.
 

Attachments

  • HScrollViewHelp2.zip
    10.5 KB · Views: 263
Upvote 0

WiLey2000

Member
Licensed User
Longtime User
Thanks again klaus!

Your sample worked great, but when i copied and pasted the ChangeHeaders
sub, I get an error when i compile:

Compiling code. Error
Error compiling program.
Error description: Unknown member: getheadervalues
Occurred on line: 45
h = DisplayWeek.GetHeaderValues' gets the haeder values
Word: getheadervalues

Not sure why, any ideas?

John
 
Upvote 0

WiLey2000

Member
Licensed User
Longtime User
I figured it out. I forgot to copy the two routines to the table class.

Can I remove the Select Row Color when selecting a cell?

John
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Yes, you can modify the ShowRow routine in the Table class like below.
B4X:
Private Sub ShowRow(row As Int)
    If visibleRows.ContainsKey(row) Then Return
    'Log("ShowRow: " & row)
    Dim lbls() As Label
    Dim values() As String
    lbls = GetLabels(row)
    values = Data.Get(row)
    visibleRows.Put(row, lbls)
    Dim rowColor() As Object
'    If row = SelectedRow Then
'        rowColor = SelectedDrawable
'    Else If row Mod 2 = 0 Then
    If row Mod 2 = 0 Then
        rowColor = Drawable1
    Else
        rowColor = Drawable2
    End If
    For I = 0 To lbls.Length - 1
        SV.Panel.AddView(lbls(I), Header.GetView(I).Left, row * RowHeight, Header.GetView(I).Width, _
            RowHeight - 1dip)
        lbls(I).Text = values(I)
        lbls(I).Background = rowColor(I)
    Next
End Sub
Best regards.
 
Upvote 0

WiLey2000

Member
Licensed User
Longtime User
Thanks again klaus!

Last thing on this HorizontalScrollView.

I need to select the header date and input it into etxtDate field with format like: mm-dd-yyyy

This is what I tried, but displays wrong info [Ljava.lang.String;@410112a8
B4X:
Sub DisplayWeek_HeaderClick (Col As Int)
   Log("HeaderClick: " & Col)
   etxtDate.Text = DisplayWeek.GetHeaderValues
End Sub
I believe i have to run it thru the ChangeHeader sub to get proper date format without the time.

John
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Your code won't work because DisplyWeek.GetHeaderValues returns a string array with the header values with the new format.
I suggest you to add a global string array with the dates for each column and fill it in the ChangeHeaders routine with the desired format.
Then the Sub DisplyWeek_HeaderClick routine is quite simple:
B4X:
Sub DisplyWeek_HeaderClick(col As Int)
    etxtDate.Text = Dates(col)
End Sub
Attached a modifyed version.

Best regards.
 

Attachments

  • HScrollViewHelp3.zip
    10.7 KB · Views: 320
Upvote 0

WiLey2000

Member
Licensed User
Longtime User
Hey klaus i have another question.

I now want to load my horizontalscrollview into a panel on AddTime Layout.

My panel name: pnlAddTime

B4X:
Activity_Create(FirstTime As Boolean)
   DisplayWeek.Initialize(Me, "DisplayWeek", 0)
   DisplayWeek.AddToActivity(Activity, 0, 10%y, 100%x, 22%y)
   Activity.LoadLayout("AddTime")
   DisplayWeek.LoadTableFromCSV(File.DirAssets, "tblCurrentWeekJobs.csv", True)
   DisplayWeek.SetColumnsWidths(Array As Int(130dip, 130dip, 130dip, 130dip, 130dip, 130dip, 130dip, 130dip))
   
   lblDisplayedWeek.Text = "Current Week"
   ChangeHeaders
End Sub

How do i load this into my panel pnlAddTime?

Thanks again!
John
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…