編輯:關於Android編程
TextInputActivity.java:
package com.iwanghang.coordinatordemo;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
public class TextInputActivity extends AppCompatActivity implements TextWatcher {
TextInputLayout text_input;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_text_input);
text_input = (TextInputLayout) findViewById(R.id.text_input);
// 監聽editText的內容改變
// 實現 addTextChangedListener 的 beforeTextChanged onTextChanged
// afterTextChanged 這3個方法
text_input.getEditText().addTextChangedListener(this);
}
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
if (editable.length()<6) {
text_input.setError("用戶名必須為6位或以上");
text_input.setErrorEnabled(true);
} else {
text_input.setErrorEnabled(false);
}
}
}
activity_input_text.xml:
Android4.4 訪問外部存儲詳解及實例
Android4.4 訪問外部存儲在Android 4.4系統中,外置存儲卡(SD卡)被稱為二級外部存儲設備(secondary storage),應用程序已
Android簡易實戰教程-- AsyncTask異步倒計時
本篇小案例,完成一個倒計時。方式選擇AsyncTask。代碼貼在下面:布局文件soeasy: 接著活動代碼:package com.example.as
Android開發-之環境的搭建(圖文詳解)
關於Android開發可以使用的工具有eclipse和Android studio等,這兩個工具都各有各的好處和不足。studio是谷歌推出的一款開發工具,而我們都知道A
全軍盡墨的Android應用:社會化授權登錄及分享安全漏洞
隨著微信微博等社會化媒體的火熱,第三方登錄迅速成為一種快捷注冊的方式,社會化分享也成為一種知識快速傳播的渠道。在移動端,幾乎大多數應用都接入了第三方登錄或者分享組件,尤其