Android Question Return Text of each line by reflection lib

ArminKH

Well-Known Member
Hi all
I want to return the text of each line in a view(like label) by using reflection library.(i can do this by while--loop and some calculation but looking for a faster way to do it)
Pls help me to find out the best method of doing this just by reflection library
 
Last edited:

ArminKH

Well-Known Member
tnx mr stevel05 and DonManfred
thats work perfectly now with reflection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
and not work by using java object !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Untitled.png
 
Upvote 0

ArminKH

Well-Known Member
@stevel05
im sorry excuse me again
can u please convert all java object parts in page 1 to reflection?because i dont want to use 2 lib together
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I think there should be enough info there for you to try it yourself. Post if you get a specific problem.
 
Upvote 0

ArminKH

Well-Known Member
I think there should be enough info there for you to try it yourself. Post if you get a specific problem.
here is my code i am sorry mr stevel but i try always but i am not familar with java ok tnx

B4X:
Private Sub SaveTextLineByLine(ViewName As View)
    Dim Source As Reflector
        Source.Target=ViewName
    Dim Text As String=Source.RunMethod2("getText",Null,"java.lang.string")
    Dim Layout As Reflector=Source.RunMethod("getLayout")
    Dim LineCount As Int=Source.RunMethod2("getLineCount",Null,"java.lang.int")
    Dim TextByLine(LineCount) As String

    Dim LineStart,LineEnd As Int
        Dim R As Reflector
               R.Target = Layout
        Dim A As Int
            For A=0 To LineCount - 1
                LineStart=R.RunMethod2("getLineStart",A,"java.lang.int")
                LineEnd=R.RunMethod2("getLineEnd",A,"java.lang.int")
                TextByLine(A)=Text.SubString2(LineStart,LineEnd).Trim
            Next
End Sub
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You have to set the target with the Reflector, you can't do:

B4X:
Dim Layout As Reflector=Source.RunMethod("getLayout")

It needs to be:
B4X:
Dim Layout As Reflector
    Layout.Target=Source.RunMethod("getLayout")
 
Upvote 0
Top