Sub Activity_KeyUp (KeyCode As Int) As Boolean
Log(GetMasterPosition(clvMasterCh.ScrollPosition))
End Sub
Sub GetMasterPosition(ScrollPosition As Int) As Int
Log(ScrollPosition)
Return Round(ScrollPosition/252)
End Sub
Public Sub ScrollToPosition(ScrollPosition As Int)
sv.ScrollToNow(ScrollPosition)
End Sub
'Scrolls the list to the specified item.
Public Sub JumpToItem(Index As Int)
Your app crashed on this line:
JSON.Initialize(File.ReadString(File.DirDefaultExternal, "channels.json"))
File not found.
'CALL - 0st Item
Activity_KeyUp ("20")
Sub Button1_Click
Log(GetMasterPosition(clvMasterCh.ScrollPosition))
clvMasterCh.JumpToItem(20)
End Sub
'Scrolls the list to the specified item.
Public Sub JumpToItem(Index As Int)
Dim top As Int
Dim p As Panel
For i = 0 To Min(Index - 1, items.Size - 1)
p = panels.Get(i)
top = top + p.Height + dividerHeight
Next
sv.ScrollPosition = top
'The scroll position doesn't always gets updated without two calls to DoEvents
'DoEvents
'sv.ScrollPosition = top
'DoEvents
End Sub
Public Sub JumpToItem(Index As Int)
Dim top As Int
Dim p As Panel
For i = 0 To Min(Index - 1, items.Size - 1)
p = panels.Get(i)
top = top + p.Height + dividerHeight
Next
CallSubDelayed2(Me,"JumpTo",top)
'The scroll position doesn't always gets updated without two calls to DoEvents
'DoEvents
'sv.ScrollPosition = top
'DoEvents
End Sub
public Sub JumpTo(item As Int)
sv.ScrollPosition = item
End Sub
remove this from Activity_Create ..(this is why app was crashing)
B4X:'CALL - 0st Item Activity_KeyUp ("20")
Activity_KeyUp(KeyCode as Int) is expecting an INT anyway .. Not A String
for testing i have placed a button on the main panel .. All works fine.
B4X:Sub Button1_Click Log(GetMasterPosition(clvMasterCh.ScrollPosition)) clvMasterCh.JumpToItem(20) End Sub
'ADD - Master Items
For Ch = 1 To 50
clvMasterCh.Add(CreateChannelListMaster(Ch, clvMasterCh.AsView.Width, 169dip, "hayatbih.png", "Channel "&Ch, "Inspektori za životinje", "12:45", "13:10", "Na prvoj liniji: Epizoda 3 Prikazuje se život leoparda u divljini kako lovi i preživljava..."), 167dip, Channels)
Next
'ADD - Master Items
For Ch = 1 To 100
clvMasterCh.Add(CreateChannelListMaster(Ch, clvMasterCh.AsView.Width, 169dip, "hayatbih.png", "Channel "&Ch, "Inspektori za životinje", "12:45", "13:10", "Na prvoj liniji: Epizoda 3 Prikazuje se život leoparda u divljini kako lovi i preživljava..."), 167dip, Channels)
Next
Try to put 100items or more then scrolling will not work any more full scroll only half..i tryed now and i think there is bug in scrollview component or code...
Sub GetMasterPosition(ScrollPosition As Int) As Int
Log(ScrollPosition)
Return Round(ScrollPosition/250)
End Sub
That first 50items have height in scoroller 250 witch is correct if i put 60 items or more it height is 125 and why is this half?
'ADDVIEW - CustomListViews
Activity.AddView(clvMasterCh.AsView, 97dip, 389dip, 407dip, 167dip) '@@@ 167Dip size of the ScrollView Window
'ADD - Master Items
For Ch = 0 To 100
clvMasterCh.Add(CreateChannelListMaster(Ch, clvMasterCh.AsView.Width, 169dip, "hayatbih.png", "Channel Test", "12:45", "13:10", "Testing 123"), 167dip, Channels)
Next
'@@@ 167dip is the size of pnlMaster (that contains your other views)
I ime getting half scrool like in picture in first post (greeb background half scrolled panel down)...so i don't get idea why is on my android device over 50items scrolling half?
That first 50items have height in scoroller 250 witch is correct if i put 60 items or more it height is 125 and why is this half?
i think that scrollview have limitation in android os to 50 items ( or limit 50items x 250dip = 12500dip)
CustomListView is an implementation of a list based on ScrollView
CustomListView is suited for lists of up to 1000 or 2000 items.
Ok can you make example of 150items or more in scrollview and post here demo code? I im currently programming epg for apk...but have limit to 50 items in channels list and working perfectly...but i need for 150 to 500 items scroller...i im using remote control...not smartphone android so touch is not good for me .........
Thanks.