I read value from EditText and write it to TextView
editTitle1.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable
I edited the answer given by ramaral he used wrong escape sequence
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;
}
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;
}
Add the following 2 attributes to the TextView definition:
android:singleLine="false"
android:maxems="10"