Non-working code fragments

wdegler

Active Member
Licensed User
Longtime User
I see no other applicable threads for such questions as the following:

The word "one" shows on the screen as expected, but no longer when I put the ListView into the Panel of a ScrollView. Why?

The code:

Sub Activity_Create(FirstTime As Boolean)
Dim SV As ScrollView
Dim Pnl As Panel
Dim LstVw As ListView

SV.Initialize(100)
Pnl.Initialize("")
Activity.AddView(SV,100,100,200,200)
Pnl=SV.Panel

LstVw.Initialize("")
'Activity.AddView(LstVw,100,100,200,200)
LstVw.AddSingleLine("one")

SV.Pnl.AddView(LstVw,100,100,200,200)
End Sub

Ultimately, I want two lists side by side that will scroll as one on the screen.
Help!
 

eps

Expert
Licensed User
Longtime User
They zseem to have the same start coordinates and width and height, so will surely overwrite each other, no?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Your code has several problems:

- SV.Initialize(100)
here you set the height of the internal panel of the ScrollView smaller than the ScrollView itself hiding half of the content.

- SV.Pnl.AddView(LstVw,100,100,200,200)
here you set the ListView out of the visible part of the ScrollView. The coordinates of the ListView refer to the Panel NOT to the Activity so it should be: SV.Pnl.AddView(LstVw,0,0,200,200)

- You cannot scroll the ListView because the ScrollView overrides it, the ListView is inside the ScrollView.

What exactly do you want to do ?
You say 'you want two lists side by side scrolling as one'
Do these lists have the same number of items ?
If yes use one ScrollView with two columns. Even if no, it could be managed.

Best regards.
 
Upvote 0

wdegler

Active Member
Licensed User
Longtime User
That Helps

Thanks for the hint. That helped me further. I now have two ListViews in a ScrollView Panel. Now all I need is to make the ListViews (or ScrollView) to scroll them together.
 
Upvote 0

wdegler

Active Member
Licensed User
Longtime User
When using the B4A emulator, how can my app find and read a data file on the Windows PC? The following cannot find any file whereEVER it is. This is not a problem on a real device.

Sub ReadFile As Boolean
Dim Found As Boolean
Dim TxtFile As String

Found=False
If FilenameEdtTxt.Text.length>0 Then
TxtFile=FilenameEdtTxt.Text & ".txt"
If File.Exists(File.DirRootExternal,TxtFile) Then
Found=True
Txt=File.ReadString(File.DirRootExternal,TxtFile)
End If
End If
Return Found
End Sub
 
Upvote 0
Top