在自定义的TextView控件中,如果第一个字符是数字,则下一个字符将是字符。如何找到其中的第一个数字字符。
在自定义的TextView控件中,如果第一个字符是数字,则下一个字符将是字符。如何找到其中的第一个数字字符。
var str = "whaever your string is..."
str.capitalize()
// Whaever your string is...
每个单词首字母大写
var str = "whaever your string is..."
val space = " "
val splitedStr = str.split(space)
str = splitedStr.joinToString (space){
it.capitalize()
}
// Whaever Your String Is...
String input= "sentence";
String output = input.substring(0, 1).toUpperCase() + input.substring(1);
textview.setText(output);
android:inputType = "textCapWords"
//This would capitalise the first letter in every word.
android:inputType = "textCapSentences"
//This would capitalise the first letter in every sentence.
String[] words = input.getText().toString().split(" ");
StringBuilder sb = new StringBuilder();
if (words[0].length() > 0) {
sb.append(Character.toUpperCase(words[0].charAt(0)) + words[0].subSequence(1, words[0].length()).toString().toLowerCase());
for (int i = 1; i < words.length; i++) {
sb.append(" ");
sb.append(Character.toUpperCase(words[i].charAt(0)) + words[i].subSequence(1, words[i].length()).toString().toLowerCase());
}
}
String titleCaseValue = sb.toString();
public static String wordCapitalize(String words)
{
String str = "";
boolean isCap = false;
for(int i = 0; i < words.length(); i++){
if(isCap){
str += words.toUpperCase().charAt(i);
}else{
if(i==0){
str += words.toUpperCase().charAt(i);
}else {
str += words.toLowerCase().charAt(i);
}
}
if(words.charAt(i)==' '){
Utility.debug(1,TAG,"Value of i : "+i+" : "+words.charAt(i)+" : true");
isCap = true;
}else{
Utility.debug(1,TAG,"Value of i : "+i+" : "+words.charAt(i)+" : false");
isCap = false;
}
}
Utility.debug(1,TAG,"Result : "+str);
return str;
}
String text = textView.getText().toString();
for(Character c : text){
if(c.isLetter){
//First letter found
break;
}