English 中文(简体)
EditText从电子邮件和密码搬走空白处
原标题:Remove blank spaces from email and password get by EditText
  • 时间:2011-11-23 15:28:55
  •  标签:
  • java
  • android
EditText recEmail=(EditText)findViewbyId(R.id.email);
EditText recPassword=(EditText)findViewbyId(R.id.password);
String email=recEmail.getText().toString();
String password=recPassword.getText().toString();

电子邮件和密码载有一开始、一带或一端str的白色空间,如果tab误。

我需要从白色空间读出文字,如果能够的话,请帮助。

advance!

最佳回答
问题回答

审判

email.replace(" ", "");
password.replace(" ", "");

a. 为达到目的,在座标和<条码>上清除白色空间。

You might want to check the String methods. Try .trim() to remove white spaces from the beginning and end.

还检查和roid:投入 电子邮件类型。

    email.trim();
    passw或d.trim();

    it remove white spaces.

    **u can also use regular expression on it f或 checking spaces 或 any specific condition**

     String string = "[email protected]";
            Pattern pattern = Pattern.compile("\s+");
            Matcher matcher = pattern.matcher(string);
            boolean check = matcher.find();
            String str = matcher.replaceAll("");
            System.out.println("String after removing all duplicate white spaces:" + str);

<EditText 
    android:inputType="textEmailAddress"/>

    Thanks




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签