E
E
Evgeny Emelyanov2016-04-03 08:01:51
Android
Evgeny Emelyanov, 2016-04-03 08:01:51

Splitting words in editText?

How can I take the part of the editText up to the space and save it to a variable? I did this:
EditText namm;
String data = editText2.getText().toString();
for(i=0; i != data.length(); i++) {if (String.valueOf(data.charAt(i)) == " ") { namm = editText2.setSelection(z, i-1);
z = i;
values ​​put("nam", namm);
values ​​put("sv", "4");
db.insert("QW", "nam", values); }
}
But writes incompatibility of types.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Myvrenik, 2016-04-03
@zhekaeev

String data = editText2.getText().toString();

String[] words = data.split(" ");

E
Evgeny Emelyanov, 2016-04-03
@zhekaeev

Thanks to all!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question