Hello,
i wonder about the difference of scrollview in B4A and B4i.
I wrote a App that connects to a ftp-server, imports a textfile via LoadCSV and shows the rows in table which is the panel of a scrollview.
I created this App for B4A and it works fine.
I did the same for B4i and the scrollview can't be scrolled - it's just fix on the screen of the iPhone and I have no idea why.
What steps are needed to solve this problem?
Do I have to 'Resize' in any way (...although it's not necessary in B4A)?
Here's the B4i-Code (without the ftp connection-data - there's no problem with the ftp-connection)
-----------------------------------------------------------------
'Code module
#Region Project Attributes
#ApplicationLabel: Pikettinfo
#Version: 1.0.0
'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
'#iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
#iPhoneOrientations: Portrait
'#iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
#Target: iPhone
#ATSEnabled: True
#MinVersion: 7
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Dim FTP As FTP
Dim EPSFtpServer As String = "ftp.energie-logistik.ch"
Dim ImageView1 As ImageView
Dim Label1 As Label
Dim Button1 As Button
Dim Button2 As Button
Dim su As StringUtils
Dim PikettListe As List
Dim SV As ScrollView
Dim Header As Panel
Dim Table As Panel
Dim NumberOfColumns, RowHeight, ColumnWidth As Int
Dim HeaderColor, TableColor, FontColor, HeaderFontColor As Int
'Dim FontSize As Float
Type RowCol (Row As Int, Col As Int)
Dim Alignment As Int
Dim SelectedRow As Int
Dim SelectedRowColor As Int
'Table settings
HeaderColor = Colors.Gray
NumberOfColumns = 5
RowHeight = 30dip
TableColor = Colors.White
FontColor = Colors.Black
HeaderFontColor = Colors.White
'FontSize = 12
'Alignment = Gravity.CENTER 'change to Gravity.LEFT or Gravity.RIGHT for other alignments.
SelectedRowColor = Colors.Blue
End Sub
Private Sub Application_Start (Nav As NavigationController)
'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Pikettinfo"
Page1.RootPanel.Color = Colors.White
Page1.RootPanel.LoadLayout("pikinfomain")
NavControl.ShowPage(Page1)
FTP.Initialize("FTP", EPSFtpServer, 21, "user", "PW")
ImageView1.Bitmap = LoadBitmap(File.DirAssets, "eps_logo_de.png")
Label1.Text = "EPS Pikettplanung aktuell"
Button1.Text = "Daten holen"
Button2.Visible = False
If File.Exists(File.DirTemp, "pikett-info.txt") Then File.Delete(File.DirTemp, "pikett-info.txt")
Table.Initialize("")
SV.Initialize("SV",85%x,55%y)
End Sub
Sub Button1_Click
Button1.Visible = False
SV.ScrollEnabled = True
Table = SV.Panel
Table.Color = TableColor
Page1.RootPanel.AddView(SV, 5%x, 25%y, 90%x, 80%y)
ColumnWidth = SV.Width / NumberOfColumns
SelectedRow = -1
'add header
SetHeader(Array As String("Tag", "Datum", "Schicht", "Reserve", "IT-Pikett"))
FTP.DownloadFile("/info_client/pikett-info/pikett-info.txt", False, File.DirTemp, "pikett-info.txt")
FTP.List("info_client/pikett-info/")
Sleep(1000)
PikettListe = su.LoadCSV(File.DirTemp, "pikett-info.txt", ";")
For Each Row() As String In PikettListe
' You can access the LINE with
' dim s as string = Row(0) ' 1. line
Dim values() As String = Row ' get the columns from one line...
' use values to the access the columns... 0 to x (values(0) 1st column, value(1) the second....)
'For Each n As String In Row
Dim Zeile As String
Zeile = values(0) & ", " & values(1) & ", " & values(2) & ", " & values(3) & ", " & values(4)
Log("Zeile: " & Zeile)
'ListView1.AddSingleLine(n)
AddRow(Array As String(values(0), values(1), values(2), values(3), values(4)))
Next
ImageView1.Left = 5%x
Button2.Width = 70dip
Button2.Height = 40dip
Button2.Top = ImageView1.Top
Button2.Left = ImageView1.Left + ImageView1.Width + 20
Button2.Text = "refresh"
Button2.Visible = True
SV.BringToFront
End Sub
Sub Button2_Click
Table.RemoveAllViews
Table = SV.Panel
Table.Color = TableColor
'Activity.AddView(SV, 5%x, 25%y, 90%x, 80%y)
ColumnWidth = SV.Width / NumberOfColumns
SelectedRow = -1
'add header
SetHeader(Array As String("Tag", "Datum", "Schicht", "Reserve", "IT-Pikett"))
FTP.DownloadFile("/info_client/pikett-info/pikett-info.txt", False, File.DirTemp, "pikett-info.txt")
FTP.List("info_client/pikett-info/")
Sleep(1000)
PikettListe = su.LoadCSV(File.DirTemp, "pikett-info.txt", ";")
For Each Row() As String In PikettListe
' You can access the LINE with
' dim s as string = Row(0) ' 1. line
Dim values() As String = Row ' get the columns from one line...
' use values to the access the columns... 0 to x (values(0) 1st column, value(1) the second....)
'For Each n As String In Row
Dim Zeile As String
Zeile = values(0) & ", " & values(1) & ", " & values(2) & ", " & values(3) & ", " & values(4)
Log("Zeile: " & Zeile)
'ListView1.AddSingleLine(n)
AddRow(Array As String(values(0), values(1), values(2), values(3), values(4)))
Next
End Sub
Sub SetHeader(Values() As String)
'If Header.IsInitialized Then Return 'should only be called once
Header.Initialize("")
For i = 0 To NumberOfColumns - 1
Dim l As Label
l.Initialize("header")
l.Text = Values(i)
'l.Gravity = Gravity.CENTER
'l.TextSize = FontSize
l.Color = HeaderColor
l.TextColor = HeaderFontColor
l.Tag = i
Header.AddView(l, ColumnWidth * i, 0, ColumnWidth, RowHeight)
Next
Page1.RootPanel.AddView(Header, SV.Left, SV.Top - RowHeight, SV.Width, RowHeight)
End Sub
Sub AddRow(Values() As String)
If Values.Length <> NumberOfColumns Then
Log("Wrong number of values.")
Return
End If
Dim lastRow As Int
lastRow = NumberOfRows
For i = 0 To NumberOfColumns - 1
Dim l As Label
l.Initialize("cell")
l.Text = Values(i)
'l.Gravity = Alignment
'l.TextSize = FontSize
l.TextColor = FontColor
Dim rc As RowCol
rc.Initialize
rc.Col = i
rc.Row = lastRow
l.Tag = rc
Table.AddView(l, ColumnWidth * i, RowHeight * lastRow, ColumnWidth, RowHeight)
Next
Table.Height = NumberOfRows * RowHeight
End Sub
Sub NumberOfRows As Int
Return Table.NumberOfViews / NumberOfColumns
End Sub
Sub FTP_DownloadProgress (ServerPath As String, TotalDownloaded As Long, Total As Long)
Dim s As String
's = "Downloaded " & Round(TotalDownloaded / 1000) & "KB"
s = "Downloaded " & TotalDownloaded & "Bytes"
If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
Log(s)
End Sub
Sub FTP_DownloadCompleted (ServerPath As String, Success As Boolean)
Log(EPSFtpServer & ServerPath & ", Success=" & Success)
If Success = False Then Log(LastException.Message)
End Sub
Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
Log(ServerPath)
If Success = False Then
Log(LastException)
Else
For i = 0 To Folders.Length - 1
Log(Folders(i).Name)
Next
For i = 0 To Files.Length - 1
Log(Files(i).Name & ", " & Files(i).Size & ", " & DateTime.Date(Files(i).Timestamp))
Next
End If
End Sub
Private Sub Page1_Resize(Width As Int, Height As Int)
End Sub
Private Sub Application_Background
File.Delete(File.DirTemp, "pikett-info.txt")
FTP.DownloadFile("/info_client/pikett-info/pikett-info.txt", False, File.DirTemp, "pikett-info.txt")
FTP.List("info_client/pikett-info/")
End Sub
---------------------------------------------------------------------------------
Thanks for help
i wonder about the difference of scrollview in B4A and B4i.
I wrote a App that connects to a ftp-server, imports a textfile via LoadCSV and shows the rows in table which is the panel of a scrollview.
I created this App for B4A and it works fine.
I did the same for B4i and the scrollview can't be scrolled - it's just fix on the screen of the iPhone and I have no idea why.
What steps are needed to solve this problem?
Do I have to 'Resize' in any way (...although it's not necessary in B4A)?
Here's the B4i-Code (without the ftp connection-data - there's no problem with the ftp-connection)
-----------------------------------------------------------------
'Code module
#Region Project Attributes
#ApplicationLabel: Pikettinfo
#Version: 1.0.0
'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
'#iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
#iPhoneOrientations: Portrait
'#iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
#Target: iPhone
#ATSEnabled: True
#MinVersion: 7
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Dim FTP As FTP
Dim EPSFtpServer As String = "ftp.energie-logistik.ch"
Dim ImageView1 As ImageView
Dim Label1 As Label
Dim Button1 As Button
Dim Button2 As Button
Dim su As StringUtils
Dim PikettListe As List
Dim SV As ScrollView
Dim Header As Panel
Dim Table As Panel
Dim NumberOfColumns, RowHeight, ColumnWidth As Int
Dim HeaderColor, TableColor, FontColor, HeaderFontColor As Int
'Dim FontSize As Float
Type RowCol (Row As Int, Col As Int)
Dim Alignment As Int
Dim SelectedRow As Int
Dim SelectedRowColor As Int
'Table settings
HeaderColor = Colors.Gray
NumberOfColumns = 5
RowHeight = 30dip
TableColor = Colors.White
FontColor = Colors.Black
HeaderFontColor = Colors.White
'FontSize = 12
'Alignment = Gravity.CENTER 'change to Gravity.LEFT or Gravity.RIGHT for other alignments.
SelectedRowColor = Colors.Blue
End Sub
Private Sub Application_Start (Nav As NavigationController)
'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Pikettinfo"
Page1.RootPanel.Color = Colors.White
Page1.RootPanel.LoadLayout("pikinfomain")
NavControl.ShowPage(Page1)
FTP.Initialize("FTP", EPSFtpServer, 21, "user", "PW")
ImageView1.Bitmap = LoadBitmap(File.DirAssets, "eps_logo_de.png")
Label1.Text = "EPS Pikettplanung aktuell"
Button1.Text = "Daten holen"
Button2.Visible = False
If File.Exists(File.DirTemp, "pikett-info.txt") Then File.Delete(File.DirTemp, "pikett-info.txt")
Table.Initialize("")
SV.Initialize("SV",85%x,55%y)
End Sub
Sub Button1_Click
Button1.Visible = False
SV.ScrollEnabled = True
Table = SV.Panel
Table.Color = TableColor
Page1.RootPanel.AddView(SV, 5%x, 25%y, 90%x, 80%y)
ColumnWidth = SV.Width / NumberOfColumns
SelectedRow = -1
'add header
SetHeader(Array As String("Tag", "Datum", "Schicht", "Reserve", "IT-Pikett"))
FTP.DownloadFile("/info_client/pikett-info/pikett-info.txt", False, File.DirTemp, "pikett-info.txt")
FTP.List("info_client/pikett-info/")
Sleep(1000)
PikettListe = su.LoadCSV(File.DirTemp, "pikett-info.txt", ";")
For Each Row() As String In PikettListe
' You can access the LINE with
' dim s as string = Row(0) ' 1. line
Dim values() As String = Row ' get the columns from one line...
' use values to the access the columns... 0 to x (values(0) 1st column, value(1) the second....)
'For Each n As String In Row
Dim Zeile As String
Zeile = values(0) & ", " & values(1) & ", " & values(2) & ", " & values(3) & ", " & values(4)
Log("Zeile: " & Zeile)
'ListView1.AddSingleLine(n)
AddRow(Array As String(values(0), values(1), values(2), values(3), values(4)))
Next
ImageView1.Left = 5%x
Button2.Width = 70dip
Button2.Height = 40dip
Button2.Top = ImageView1.Top
Button2.Left = ImageView1.Left + ImageView1.Width + 20
Button2.Text = "refresh"
Button2.Visible = True
SV.BringToFront
End Sub
Sub Button2_Click
Table.RemoveAllViews
Table = SV.Panel
Table.Color = TableColor
'Activity.AddView(SV, 5%x, 25%y, 90%x, 80%y)
ColumnWidth = SV.Width / NumberOfColumns
SelectedRow = -1
'add header
SetHeader(Array As String("Tag", "Datum", "Schicht", "Reserve", "IT-Pikett"))
FTP.DownloadFile("/info_client/pikett-info/pikett-info.txt", False, File.DirTemp, "pikett-info.txt")
FTP.List("info_client/pikett-info/")
Sleep(1000)
PikettListe = su.LoadCSV(File.DirTemp, "pikett-info.txt", ";")
For Each Row() As String In PikettListe
' You can access the LINE with
' dim s as string = Row(0) ' 1. line
Dim values() As String = Row ' get the columns from one line...
' use values to the access the columns... 0 to x (values(0) 1st column, value(1) the second....)
'For Each n As String In Row
Dim Zeile As String
Zeile = values(0) & ", " & values(1) & ", " & values(2) & ", " & values(3) & ", " & values(4)
Log("Zeile: " & Zeile)
'ListView1.AddSingleLine(n)
AddRow(Array As String(values(0), values(1), values(2), values(3), values(4)))
Next
End Sub
Sub SetHeader(Values() As String)
'If Header.IsInitialized Then Return 'should only be called once
Header.Initialize("")
For i = 0 To NumberOfColumns - 1
Dim l As Label
l.Initialize("header")
l.Text = Values(i)
'l.Gravity = Gravity.CENTER
'l.TextSize = FontSize
l.Color = HeaderColor
l.TextColor = HeaderFontColor
l.Tag = i
Header.AddView(l, ColumnWidth * i, 0, ColumnWidth, RowHeight)
Next
Page1.RootPanel.AddView(Header, SV.Left, SV.Top - RowHeight, SV.Width, RowHeight)
End Sub
Sub AddRow(Values() As String)
If Values.Length <> NumberOfColumns Then
Log("Wrong number of values.")
Return
End If
Dim lastRow As Int
lastRow = NumberOfRows
For i = 0 To NumberOfColumns - 1
Dim l As Label
l.Initialize("cell")
l.Text = Values(i)
'l.Gravity = Alignment
'l.TextSize = FontSize
l.TextColor = FontColor
Dim rc As RowCol
rc.Initialize
rc.Col = i
rc.Row = lastRow
l.Tag = rc
Table.AddView(l, ColumnWidth * i, RowHeight * lastRow, ColumnWidth, RowHeight)
Next
Table.Height = NumberOfRows * RowHeight
End Sub
Sub NumberOfRows As Int
Return Table.NumberOfViews / NumberOfColumns
End Sub
Sub FTP_DownloadProgress (ServerPath As String, TotalDownloaded As Long, Total As Long)
Dim s As String
's = "Downloaded " & Round(TotalDownloaded / 1000) & "KB"
s = "Downloaded " & TotalDownloaded & "Bytes"
If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
Log(s)
End Sub
Sub FTP_DownloadCompleted (ServerPath As String, Success As Boolean)
Log(EPSFtpServer & ServerPath & ", Success=" & Success)
If Success = False Then Log(LastException.Message)
End Sub
Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
Log(ServerPath)
If Success = False Then
Log(LastException)
Else
For i = 0 To Folders.Length - 1
Log(Folders(i).Name)
Next
For i = 0 To Files.Length - 1
Log(Files(i).Name & ", " & Files(i).Size & ", " & DateTime.Date(Files(i).Timestamp))
Next
End If
End Sub
Private Sub Page1_Resize(Width As Int, Height As Int)
End Sub
Private Sub Application_Background
File.Delete(File.DirTemp, "pikett-info.txt")
FTP.DownloadFile("/info_client/pikett-info/pikett-info.txt", False, File.DirTemp, "pikett-info.txt")
FTP.List("info_client/pikett-info/")
End Sub
---------------------------------------------------------------------------------
Thanks for help