0

I want to find \n in Edit Text then do something; I don't want to give user error when he use enter in edit text For example in my app nobody allows to write this sentence sentence: "Hello \n world"

I used this code, it worked for characters but didn't work for \n code:

private boolean findn(String t){
    for (int i=0;i<t.length();i++){
        if (t.charAt(i)=='\n'){
            return true;
        }
    }
    return false;
}
CephBirk
  • 6,422
  • 5
  • 56
  • 74
  • http://stackoverflow.com/questions/2163045/how-to-remove-line-breaks-from-a-file-in-java – ecle Jun 28 '15 at 18:11

2 Answers2

1

You can use the contains method to determine whether a String contains a given character sequence, like so:

return t.contains("\n");
Sam Estep
  • 12,974
  • 2
  • 37
  • 75
0

I fixed this problem with change digits in xml

        android:digits="@string/myAlphaNumeric"