Help Loading HSV into a Panel

WiLey2000

Member
Licensed User
Longtime User
I have been tring to figure this out with no luck. :BangHead:

If you run the attached, when you press the Add Time button it should load a horizonal scrollview. I think my pnlAddTime panel is loading over top of it.

klaus has modified an example of his for me and i have been tring to figure out how to load the horizontal scrollview to a panel instead of the Activity. I need to be able to turn panels on and off.

My main question is i need to now load the horizontal scrollview from sql database file instead of csv file. The attached has a sql database file with a table named "tblCurrentWeek". It has the same data as the csv file also included.

Thanks

John
 

Attachments

  • HSVLoadPanel.zip
    11.8 KB · Views: 191

WiLey2000

Member
Licensed User
Longtime User
I just realized i forgot to include the sql database file in the original post. :signOops:

sorry
 

Attachments

  • HSVLoadPanel1.zip
    21.6 KB · Views: 187
Upvote 0

WiLey2000

Member
Licensed User
Longtime User
Can anyone help? I've been tring and can't get the table DisplayWeek to load into panel created in Designer.

I need to be able to turn visiblity off and on for this panel - pnlAddTime

B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim ST As SQL
   Dim Cursor As Cursor

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.

   Dim DisplyWeek As Table
   Dim etxtDate As EditText
   Dim Dates() As String
   Dim btnMain As Button
   Dim pnlMainMenu As Panel
   Dim btnAddTime As Button
   Dim pnlAddTime As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)

   'If FirstTime Then 
   'File.Copy(File.DirAssets,"TimeClock.sql",File.DirDefaultExternal,"TimeClock.sql")
   'End If

   'If ST.IsInitialized = False Then
    '    ST.Initialize(File.DirDefaultExternal, "jobschedule.sql", False)
   ' If

   Activity.LoadLayout("MainMenu")

End Sub

Sub LoadAddTime

   'ST.ExecQuery("Select * FROM tblCurrentWeek")

   Activity.LoadLayout("AddTime")
   'Activity.Panel.LoadLayout("pnlAddTime")
   DisplyWeek.Initialize(pnlAddTime, "DisplyWeek", 0)
   DisplyWeek.AddToActivity(pnlAddTime, 0, etxtDate.Top + etxtDate.Height + 4dip, 100%x, 20%y)
   
   DisplyWeek.LoadTableFromCSV(File.DirAssets, "tblCurrentWeekJobs.csv", True)
   DisplyWeek.SetColumnsWidths(Array As Int(130dip, 130dip, 130dip, 130dip, 130dip, 130dip, 130dip, 130dip))
   ChangeHeaders
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub DisplyWeek_CellClick (Col As Int, Row As Int)
   Log("(DisplyWeek) CellClick: " & Col & " , " & Row)
   Activity.Title = DisplyWeek.GetValue(Col, Row)
End Sub

Sub btnExit_Click
   ExitApplication
End Sub

Sub ChangeHeaders
   Dim h() As String
   Dim Dates(DisplyWeek.NumberOfColumns) As String
   Dim i As Int
   
   h = DisplyWeek.GetHeaderValues                     ' gets the haeder values

   df = DateTime.DateFormat                              ' gets the current date format
   For i = 0 To DisplyWeek.NumberOfColumns - 1
      Dim txt() As String
      txt = Regex.Split(" ", h(i))                     ' splits the the date and time
      Dim DateTicks As Long
      Dim df As String
      DateTime.DateFormat = "MM/dd/yyyy"            ' sets the date format according to your csv file
      DateTicks = DateTime.DateParse(txt(0))      ' transforms the date to ticks
      
      DateTime.DateFormat = "MM-dd-yyyy"            ' sets the date format according to your csv file
      Dates(i) = DateTime.Date(DateTicks)            ' sets the header dates in MM-dd-yyyy format
      
      DateTime.DateFormat = "MMM-yy  EEE-dd"      ' sets the date format according to your request
      h(i) = DateTime.Date(DateTicks)                  ' sets the header text with the new format
      h(i) = h(i).Replace(".", "")                     ' removes unnecessary dots
   Next
   DateTime.DateFormat = df                              ' sets the date format back to the current one
   DisplyWeek.SetHeaderValues(h)
End Sub

Sub DisplyWeek_HeaderClick(col As Int)
   etxtDate.Text = Dates(col)
End Sub

Sub btnMain_Click
   Activity.LoadLayout("MainMenu")
End Sub
Sub pnlMainMenu_Click
   
End Sub
Sub btnAddTime_Click
   Activity.LoadLayout("AddTime")
End Sub
Sub pnlAddTime_Click
   
End Sub

Thanks

John
 
Upvote 0

WiLey2000

Member
Licensed User
Longtime User
I had that the first time and nothing displayed. than I noticed that I was not calling LoadCurrentWeek sub. DA :signOops:
Here's what I changed:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("MainMenu")

End Sub

Sub LoadAddTime
   'Activity.LoadLayout("AddTime")  <== Removed. Is been loaded on btnAddTime_Click
   DisplyWeek.Initialize(Me, "DisplyWeek", 0)
   DisplyWeek.AddToActivity(pnlAddTime, 0, etxtDate.Top + etxtDate.Height + 4dip, 100%x, 20%y)
   
   DisplyWeek.LoadTableFromCSV(File.DirAssets, "tblCurrentWeekJobs.csv", True)
   DisplyWeek.SetColumnsWidths(Array As Int(130dip, 130dip, 130dip, 130dip, 130dip, 130dip, 130dip, 130dip))
   ChangeHeaders
End Sub

Sub btnAddTime_Click
   Activity.LoadLayout("AddTime")
   LoadAddTime        '<== Added This. I was not loading table
End Sub

How do I change from loading data from a csv file to load it from a table in a sql file?

Thanks Erel!

John
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I don't want to write the program for you so I give some guidelines below.
The best way to learn is by doing.

First you need to define the structure of your program:

Do you want to have the different screens:
- on Panels and hiding and showing these ?
- on Activities this is how Android 'normally' should work
Have a look at Different examples with 2 layouts.

For your program you have different possibilities :
In the first case:
- one layout file with two Panels and all the views on the Panels.
- three layout files one main file with two Panels on it and 2 other files one for each Panel with the different views for each Panel
- add the two Pales by code and two layout files one for each Panel

In the second case:
- two Activities with one layout file for each Activity

In your case if the final application remains with two screens the first solution would be a good choice.
If you intend to have more then two screens I suggest you to use the second method with different Activities.
You could have a look at chapter 13.2 in the Beginner's Guide.

For the databse question I answer in your other thread.

Best regards.
 
Upvote 0
Top