Reputation: 21
I have a question:
I have entered a text in EditText, 'My Name is Khan'
I just want to print just 'Khan' in TextView (not 'My Name is Khan', just 'Khan' I want in TextView).
How to do it?
Upvotes: 2
Views: 193
Reputation: 2141
Parse your string using split.
String[] s = edittext.getText.toString().split(Pattern.quote(" "));
Then get the last word.
String name = s[s.length-1];
Now set it
textView.setText(name);
Upvotes: 5