Android Question Scroll LongTextTemplate to end of text

Alessandro71

Well-Known Member
Licensed User
Longtime User
I need to show a long list of elements in a LongTextTemplate Dialog
Since it's a chronological list, I'd like to to show it already scrolled to the last item using the following code, but it keeps opening at the top of the list
B4X:
    LongTextTemplate.Text = csText
    Dim sf As Object = Dialog.ShowTemplate(LongTextTemplate, "Ok", "", "")
    LongTextTemplate.CustomListView1.ScrollToItem(LongTextTemplate.CustomListView1.Size - 1)
    Sleep(0)
    Wait For (sf) Complete (Result As Int)
 

Alessandro71

Well-Known Member
Licensed User
Longtime User
actual code is

B4X:
    Dim sf As Object = Dialog.ShowTemplate(LongTextTemplate, "Ok", "", "")
    LongTextTemplate.CustomListView1.sv.ScrollViewOffsetY = LongTextTemplate.CustomListView1.sv.ScrollViewContentHeight
    Sleep(0)
    Wait For (sf) Complete (Result As Int)

but still Dialog show the first lines of text instead of the last ones
Sleep or no Sleep makes no difference
 
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
Try to put the Sleep before you set the scrollview offset.
moving the sleep before the offset solved the issue
just for the sake of learning: what is the rationale?
i thought i should put the sleep after setting the offset to allow the system to process the message, but putting it beforehand makes just broke my reasoning
 
Upvote 0
Top