Android Question ScrollView Get Changed Position

ronovar

Active Member
Licensed User
Longtime User
I need to get ScrollView Position when i do with my remote control up and down so when i get index of scrolled item i can then call another sub that sets scroll on another scrollview...so i put keypress event and pres Buttons UP and DOWN on remote (on the center is OK button) and nthing i get from keypress event in log viewer.

The point is to have Scrolled Position Index (like pressing OK button on scrolled item and get index..but without pressing OK button...for example: using remote i press...DOWN button (KEYCODE_DPAD_UP) and ScrollViews scrolls one item down and write in LOG index of scrolled item.

Here is what i try but i get empty in log viewer:

Code: Copy
Sub Activity_KeyPress(KeyCode As Int) As Boolean
    Select KeyCode
        Case KeyCodes.KEYCODE_DPAD_UP
            Log("DOWN")
           'HERE - i need fnction to get index from ScrollView Item
           ScrollView1.GetItem ???
    End Select  
End Sub
 
a Scrollview don't have items in the sense like a listview has items. It has panels or other views as its content. with the height of the contentviews and the scrollposition
Code: Copy
sp = scrollview1.ScrollPosition
you can compute the index of the element which is in the middle or top of the visible scrollviewpanel.
 
Upvote 0
Thanks...i get in Log Viewer Scroll Position (253, 506, 759...) so that i can compute now the problem is when i press UP or DOWN in remote it does not show Log in Log Viewer...when i press others buttons for example LEFT or RIGHT (in the middle of OK button on remote control) it shows...how to get log when UP or DOWN buttons is pressed on remote control?

Here is code that is working for ScrollView Position but i did not get idea why is KeyCodes.KEYCODE_DPAD_UP and KeyCodes.KEYCODE_DPAD_DOWN not working when scrolling on ScrollViewer component:

Code: Copy
Sub Activity_KeyPress(KeyCode As Int) As Boolean
    Log(clvMasterCh.ScrollPosition)
    Select KeyCode
        Case KeyCodes.KEYCODE_DPAD_UP
            Log("DOWN")   
    End Select
End Sub
 
Upvote 0
have you tried to use the ScrollChanged Event instead. Then you don't need to listen to your remote buttons
Code: Copy
Sub ScrollView1_ScrollChanged(Position As Int)
    Log(Position)
End Sub
 
Upvote 0
Back
Top