I was hoping Selectionstart in textview would behave like in edittext in b4a and position the cursor at the end of the string with with code 'textview1.selectionstart = textview1.text.length' and in a multiline scenario the cursor would scroll down the textview to the last character row.
I'm not getting that effect. Can you please confirm this is how the result will be for this enhanced method/property.
I was hoping Selectionstart in textview would behave like in edittext in b4a and position the cursor at the end of the string with with code 'textview1.selectionstart = textview1.text.length' and in a multiline scenario the cursor would scroll down the textview to the last character row.
I'm not getting that effect. Can you please confirm this is how the result will be for this enhanced method/property.
I have used scrollto and it works but it scrolls from the top. Can it do an incremental scroll from a different row or index. The reason being I want to fill the textview line by line and when current window is full to scroll up etc
Perhaps a new method scrollto2 that moves to the desired index without animation so we get the nextline effect similar to b4a setting selectionstart = stringlength
Sub ScrollTo2(TV As TextView,Index As Int)
Dim NaObj As NativeObject = Me
NaObj.RunMethod("Scroll::",Array(TV,Index))
#If Objc
-(void)Scroll:(UITextView*)TV :(int)Index{
[UIView setAnimationsEnabled:NO];
[TV scrollRangeToVisible:NSMakeRange(Index,0)];
[UIView setAnimationsEnabled:YES];
}
#End if
End Sub
Dim no As NativeObject
no.Initialize("UIView").RunMethod("setAnimationEnabled:", Array(False))
tv.ScrollTo(index)
no.RunMethod("setAnimationEnabled:", Array(True))
Dim no As NativeObject
no.Initialize("UIView").RunMethod("setAnimationEnabled:", Array(False))
tv.ScrollTo(index)
no.RunMethod("setAnimationEnabled:", Array(True))
The results are as follows:
JanPro
-------
Compiles fine and runs without animation however the scrolling stops after I append the 4th string to the textview. Its like the scroll resets goes back to index=0 even if I tell it to scroll to the end. Btw this is the same behaviour even without the animation being disabled, has to be a bug of sorts.
Erel
----
Compiles fine. No text appears in the textview when I implement the setanimatioenabled using your code.
How can I compensate for this ebhaviour and secondly I would like to get Erel's code working as it seems straight forward but the results are unexpected.
The results are as follows:
JanPro
-------
Compiles fine and runs without animation however the scrolling stops after I append the 4th string to the textview. Its like the scroll resets goes back to index=0 even if I tell it to scroll to the end. Btw this is the same behaviour even without the animation being disabled, has to be a bug of sorts.
Erel
----
Compiles fine. No text appears in the textview when I implement the setanimatioenabled using your code.
How can I compensate for this ebhaviour and secondly I would like to get Erel's code working as it seems straight forward but the results are unexpected.
Oh I forgot to mention. The scrolling only starts if I click on the textview scroll it up manually only then the scrolling executes properly, but again after a few appends to the textview it goes back to no scroll then I have to click on the textview manually scroll up and then it starts up again altho briefly.
Thanks for the help Erel. Please find attached a quickie example of adding text to a textview and using the original scrollto to get the textview content to scroll down to that last line.
The issues are as follows:
1) To remove the animation in moving to lastline
2) To ensure the scrolling fires as it should
3) I don't have to manually scroll down the textview for the initial scroll to take effect
Thanks for the help Erel. Please find attached a quickie example of adding text to a textview and using the original scrollto to get the textview content to scroll down to that last line.
The issues are as follows:
1) To remove the animation in moving to lastline
2) To ensure the scrolling fires as it should
3) I don't have to manually scroll down the textview for the initial scroll to take effect
Oh All this is of course after enough text is added to fill the textview and the rows must scroll up to see the new text. Hence why obviously I want to scroll to last indexed character in the textview. If this doesnt work I welcome an alternative method to try...
Ok will do in my next post and just as fyi I produced the layout via code and the layout only has the Activity object to cater for variants so it should work nicely to illustrate my intent for textview s rolling up line by line
I knew the flexible layout I would have to revisit. I cheated by coding the views rather than using the designer to fast track porting to iOS. I will have some questions on that soon enough.
On the scrolling how come it works for you and not me. Could there be a version of android sdk or something about minimum iOS version for it to function properly?