Reputation: 5904
I tryed to take the last word displayed in a textview but not works with my way. i tryed in this way:
String test = ((TextView)selectedContact).getText().toString().split(" ")[0];
But it takes always all words.
Upvotes: 0
Views: 579
Reputation: 13761
In one line:
String last = test.substring(test.lastIndexOf(" ") + 1);
This will take the substring from the last space to the end of your String
, which is what you're looking for.
Upvotes: 1
Reputation: 558
String a[] = tv.getText().toString().split(" ");
String last_text = a[a.length-1];
Upvotes: 2