当前位置: 动力学知识库 > 问答 > 编程问答 >

EdiText Android InputType

问题描述:

Looking on input types that a EditText view can have i seen "textPersonName" and i try to search a way to (if possible) split name and surname using maybe a method like editText.getName. My question is exist a method of edittext that splits name and surname in edittext? And if don't exist the best way is to use split or else?

网友答案:

The textPersonName is just a style option, for instance it capitalizes the first letter of each word. It won't help you distinguish first and last names. However you can search for spaces, for instance:

String[] names = editText.getText().toString().split(" ");

The Array of Strings will have each name in a different String. If the user entered: John Doe you would have "John" in names[0] and "Doe" in names[1].

分享给朋友:
您可能感兴趣的文章:
随机阅读: