I have code that removes the keyboard when enter is pressed. Now the issue is that the EditView has a new line inserted. I tried to get the text from the textview and remove any cartrige returns. But it does not work.
here is the code:
mUserName.setOnEditorActionListener(
new android.widget.TextView.OnEditorActionListener()
{
public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
{
InputMethodManager imm = (InputMethodManager)getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mUserName.getWindowToken(), 0);
CharSequence c=v.getText();
String h= c.toString();
v.setText(h.replaceAll("\n",""));
return false;
}
}
);
To restrict the input to only one line, use
Or,
mUserName.setSingleLine(true);