I want to limit the char per line to 15 chars. After every 15 chars I should include/add a "enter" key pressed ("\n") to the line so that the user can write without stopping. Any suggestion?
This is my EditText
xml
<EditText
android:id="@+id/ET"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:ems="10"
android:maxLength="20"
android:inputType="textMultiLine"
android:visibility="gone" />
This is my ET TextChangedListener
ET.addTextChangedListener(new TextWatcher(){
@Override
public void afterTextChanged(Editable s) {}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {}
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
if (count % 20 == 0)
{
((Editable) s).append("\n");
ET.setSelection(ET.getText().length());
}
}
});