`

各种小错

阅读更多

1. android:capitalize

该标签只适用于input时,原文如下:

 

Android Document 写道
If set, specifies that this TextView has a textual input method and should automatically capitalize what the user types. The default is "none".
 

就是说设置之后,用户输入的文字才会capitalize the input。

显示用的text需要自己改写下,就没这么好用的标签了。。代码如下:

 

        StringBuilder result = new StringBuilder();
    	String[] words = sentence.split(" ");
    	for(int i = 0; i < words.length; i++) {
    		if(i > 0) {
    			result.append(" ");
    		}
    		result.append(Character.toUpperCase(words[i].charAt(0)))
    			  .append(words[i].substring(1));
    	}

 2. String.replace()方法

     以前用下面的方式来使用该方法:

object.method(strings.replace(old, new)).

     该使用方式,是将replace方法的返回值作为参数传入object.method()

      当时以前从来未想过这个问题,今天一直妄图用strings.replace(old, new)方法来改变strings。。。

     彻底2了!!!

 

3. Android UI 异常:UnsupportedOperationException: Can't convert to dimension: type=0x1

此异常的缘由在于:我开始调整UI的时候,所有的dimensions都是hard code在layout文件中的,后期抽取出来放到dimens.xml文件,但是因为是从xlarge screen size开始调整,后期准备按比例调整其他screen size的dimens.xml。大概是因为相关的dimensions只存在于xlarge下的dimens.xml中,在默认的文件中找不到,所以会出现这个异常。

 

to be continued......

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics