Hi All,
I have been trying out ideas in Klauses SQLlight2 example.
SQLlight2 example is a Webview with a table of names of people and associated citys.
When a new record is entered it is in the Activity "Edit", if the the user returns to the "Main" activity immediately I want the new record displayed. Depending on the number of records this may require the page to be scrolled X times.
Below is the Activity_Resume in the Main activity, in this I find the "CuurentIndex" of the new record and attempt to Scroll X times to bring that record to the Webview.
Webviewextras.pagedown scrolls the page so that record just out of view at the bottom is displayed near the top of the Webview. I thought putting this in a loop to Scroll X times would bring a record further down the list into view. It doesn't, it appears to scroll down from the top each time.
Zip Attached
Any clues greatly appreciated.
Regards Roger
I have been trying out ideas in Klauses SQLlight2 example.
SQLlight2 example is a Webview with a table of names of people and associated citys.
When a new record is entered it is in the Activity "Edit", if the the user returns to the "Main" activity immediately I want the new record displayed. Depending on the number of records this may require the page to be scrolled X times.
Below is the Activity_Resume in the Main activity, in this I find the "CuurentIndex" of the new record and attempt to Scroll X times to bring that record to the Webview.
Webviewextras.pagedown scrolls the page so that record just out of view at the bottom is displayed near the top of the Webview. I thought putting this in a loop to Scroll X times would bring a record further down the list into view. It doesn't, it appears to scroll down from the top each time.
Zip Attached
Any clues greatly appreciated.
Regards Roger
B4X:
Sub Activity_Resume
Private RowID As Int 'New for SQLiteLight2MOD..
'Private TempID As Int 'New for SQLiteLight2MOD..
Private Scroll As Int
If SQL1.IsInitialized = False Then
SQL1.Initialize(File.DirInternal, "persons.db", True)
End If
ShowTable
'***** 'New for SQLiteLight2MOD. Sets CurrentIndex to correct value after Webview is sorted by SiteName in ShowTable Sub.
If NewRecord = True Then 'NewRecord set in AcitivityEdit
Private TempID As Int
RowID = SQL1.ExecQuerySingleResult("SELECT max(rowid) FROM persons") ' Find RowID of added Site which is the largest number
For CurrentIndex = 0 To RowIDList.Size - 1 'Loop through all possible values of "CurrentIndex" to find RowID
'If RowID = SQL1.ExecQuerySingleResult("SELECT rowid FROM persons WHERE rowid = " & RowIDList.Get(CurrentIndex)) Then Exit
TempID = SQL1.ExecQuerySingleResult("SELECT rowid FROM persons WHERE rowid = " & RowIDList.Get(CurrentIndex))
If TempID = RowID Then Exit 'Exit loop when "CurrentIndex" holds the RowID of the newest entry
Next
'************************Scroll page to display new entry on screen*****************************
wbvExtra1.pageUp(wbvTable, True) 'Sets Webview displaying top entry
Log("CurrentIndex "&CurrentIndex) 'Currentindex is the position on the table of the new entry
If CurrentIndex > 13 Then 'If new entry is off screen scroll X times to show on screen
Scroll = CurrentIndex / 13 '"Scroll" is the number of times the page has to scroll to display new entry
Log("Scroll "&Scroll)
For i = 1 To Scroll
Log("Scrolled")
wbvExtra1.pageDown(wbvTable, False)
Sleep(100)
Next
End If
NewRecord = False
End If
'******************************
If CurrentIndex >= 0 Then
UpdateSelectedEntryDisplay
End If
End Sub