Wednesday, May 18, 2022

[FIXED] How can I copy(gettext) from 50% of the textview?

Issue

Maybe this is too easy, but I can't find the solution..

For example I can copy from TextView1 with this basic code.

TextView2.setText(TextView1.getText);

I am trying to this;

How can I copy first 50% of the TextView1's text.

Thank you for helping.


Solution

Try this Use substring()

TextView2.setText(TextView1.getText().toString().substring(0,TextView1.getText().toString().length()/2));


Answered By - AskNilesh
Answer Checked By - Clifford M. (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.