I read value from EditText and write it to TextView
editTitle1.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
s = editTitle1.getText().toString();
textTitle1.setText(s);
}
});
And I want that in one line - maximum 10 characters, so if all 20 characters - it's two line in TextView with 10 chars per line. How I can do this? I try android:maxLength="10" but it does not help
Define a method that returns a string formatted to have 10 characters per line:
public String getTenCharPerLineString(String text){
String tenCharPerLineString = "";
while (text.length() > 10) {
String buffer = text.substring(0, 10);
tenCharPerLineString = tenCharPerLineString + buffer + "/n";
text = text.substring(10);
}
tenCharPerLineString = tenCharPerLineString + text.substring(0);
return tenCharPerLineString;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With