小知识点积累

   android中EditText的字数统计取巧方式:

mInputEditText.addTextChangedListener(new TextWatcher() {
	@Override
	public void onTextChanged(CharSequence s, int start, int before, int count) {
		int[] params = SmsMessage.calculateLength(s, false);
        int msgCount = params[0];//拆分的短信条数
        int inputCount = params[1];//已经输入的字数
        int remainInputCount = params[2];//还可以输入的字数
	}

	@Override
	public void beforeTextChanged(CharSequence s, int start, int count, int after) {
	}

	@Override
	public void afterTextChanged(Editable s) {
	}
});

 

android:excludeFromRecents="true" //从字面意思猜测应该就是从最近的任务列表中清除
android:completionThreshold=”1″ //属性设置了一个阀值,规定用户打了多少字符之后才出现自动提示,默认值是2,我们在这里改成了1。

EditTextView.getTextSize()得到的文字大小与其在xml中配置的值*屏幕密度有关.

例如xml中配置android:textSize="18sp",且该手机的屏幕密度为context.getResources().getDisplayMetrics().density 得到的值为1.5 则getTextSize()算出的结果是27.0

//if lack of this command,android2.2 may throw SocketException:back address family

System.setProperty("java.net.preferIPv6Addresses", "false");

<?xml version="1.0" encoding="UTF-8"?>
<resources>
	<!-- AddressPadMini -->
    <declare-styleable name="AddressPadMini">
        <!-- Separator, Default is ',' -->
        <attr name="separator"  format="string"/>
        <!-- Competion threshold, Default is 2 -->
        <attr name="threshold"  format="integer|reference"/>
        <!-- Address button backgroud -->
        <attr name="addressBg"  format="reference|color"/>
        <!-- Address button click backgroud -->
        <attr name="selectedAddressBg" format="reference|color"/>
        <!-- Address text color -->
        <attr name="addressTextColor" format="reference|color"/>
        <!-- Selected address text color -->
        <attr name="selectedAddressTextColor" format="reference|color"/>
        <!-- Cache size of duplication checking -->
        <attr name="cacheSize"  format="integer|reference"/>
        <!-- Expand when addresses more than specify count -->
        <attr name="expandAt"   format="integer|reference"/>
        <!-- Expand specify number of addresses on each click --> 
        <attr name="expandStep" format="integer|reference"/>
        <!-- Inner decorator type -->
        <attr name="decoratorType">
            <enum name="mail"       value="0"/>
            <enum name="phone_mail" value="1"/>
        </attr>
        <!-- Read only mode -->
        <attr name="readOnly" format="boolean"/>
        <!-- Single line hint style -->
        <attr name="singleLineHintStyle">
            <enum name="text"       value="0"/>
            <enum name="button"     value="1"/>
        </attr>
    <!-- =============================== -->
    <!-- App package class attributes -->
    <!-- =============================== -->
    <eat-comment />
    </declare-styleable>
</resources>


标签 <eat-comment /> 的作用: 合并标签

以下为XML标志符的数字和字符串转义符 
"     (&#34; 或 &quot;) 
'     (&#39; 或 &apos;) 
&     (&#38; 或 &amp;) 
lt(<) (&#60; 或 &lt;) 
gt(>) (&#62; 或 &gt;) 

下面的字符在 [XML]中被定义为 空白(whitespace)字符: 
空格 (&#x0020;) 
Tab (&#x0009;) 
回车 (&#x000D;) 
换行 (&#x000A;)

猜你喜欢

转载自ezfantasy.iteye.com/blog/1849539