全面解析Android中對(duì)EditText輸入實(shí)現(xiàn)監(jiān)聽的方法

在 Android design support 包中提供了一種在輸入不合適字符時(shí)一直顯示的提示方式來顯示,現(xiàn)在已經(jīng)開始在更多的應(yīng)用上被使用了;這些 Android app 在顯示他們的錯(cuò)誤提示時(shí)采用的不同的方式常常讓人感覺非常的不和諧。
即這個(gè)一直顯示的錯(cuò)誤消息是在 TextInputLayout 中的 EditText 周圍的。這也是,作為一個(gè)獎(jiǎng)勵(lì),提供了材料設(shè)計(jì)風(fēng)格中,活潑的浮動(dòng)標(biāo)簽在一個(gè) APP 的用戶體驗(yàn)中常常是最無聊的部分。
這里來討論如何在你的輸入表單上去創(chuàng)建一個(gè)通用的、可重用的組件來實(shí)現(xiàn)所有的字段驗(yàn)證。因?yàn)槟阆胍谟脩舾恼隋e(cuò)誤的輸入時(shí)就去隱藏錯(cuò)誤提示。我們可以通過使用 TextWatchers 來實(shí)現(xiàn)驗(yàn)證。
不幸的是,在最新的support library (23.1)中,一旦你隱藏了錯(cuò)誤提示,讓它們?cè)亠@示的時(shí)候,會(huì)有一個(gè) bug。所以這個(gè)例子是建立在這個(gè) 23.0.1 support library 上的。此時(shí)我對(duì)這個(gè) support library 是又愛又恨的關(guān)系——每次一個(gè)新版本發(fā)布的時(shí)候我就像一個(gè)小孩在過圣誕節(jié):我沖下樓去看圣誕老人送來的新玩具是什么,但是發(fā)現(xiàn)他帶來新玩具的時(shí)候,我的新玩具火車缺少一些零件,他還弄壞了一些我最喜歡的玩具,還把煙囪里的煙灰踩到了地?cái)偵稀?/p>
創(chuàng)建我們通用的類
把我的小埋怨放到一邊,讓我們創(chuàng)建一個(gè)實(shí)現(xiàn)了 TextWatcher 的接口的抽象的 ErrorTextWatcher 類。對(duì)于這個(gè)簡(jiǎn)單的例子,我想說我們的 TextWatcher 總是帶有 TextInputLayout,而且它可以顯示一個(gè)簡(jiǎn)單的錯(cuò)誤消息。你的用戶體驗(yàn)設(shè)計(jì)團(tuán)隊(duì)可能想要顯示不同的錯(cuò)誤——如:“密碼不能為空”,“密碼必須包含至少一個(gè)數(shù)字”,“請(qǐng)輸入至少 4 個(gè)字符”等?!?但為了簡(jiǎn)單起見,每個(gè) TextWatcher 我將只展示如何實(shí)現(xiàn)一個(gè)簡(jiǎn)單的消息。
public abstract class ErrorTextWatcher implements TextWatcher {
private TextInputLayout mTextInputLayout;
private String errorMessage;
protected ErrorTextWatcher(@NonNull final TextInputLayout textInputLayout, @NonNull final String errorMessage) {
this.mTextInputLayout = textInputLayout;
this.errorMessage = errorMessage;
}
我還給這個(gè)抽象類增加了一些通用的方法:
public final boolean hasError() {
return mTextInputLayout.getError() != null;
}
protected String getEditTextValue() {
return mTextInputLayout.getEditText().getText().toString();
}
我也想要我所有的 ErrorTextWatchers 都實(shí)現(xiàn) validate() 方法,如果如果輸入是正確的就返回 true,這樣能簡(jiǎn)單的去顯示或隱藏錯(cuò)誤:
public abstract boolean validate();
protected void showError(final boolean error) {
if (!error) {
mTextInputLayout.setError(null);
mTextInputLayout.setErrorEnabled(false);
} else {
if (!errorMessage.equals(mTextInputLayout.getError())) {
// Stop the flickering that happens when setting the same error message multiple times
mTextInputLayout.setError(errorMessage);
}
mTextInputLayout.requestFocus();
}
}
在我的代碼上,這個(gè)庫在這里有另外一個(gè)功能:在我看來通過設(shè)置錯(cuò)誤提示的 enabled 為 false,你就應(yīng)該能隱藏錯(cuò)誤提示,但是這會(huì)讓 EditText 的下劃線仍然顯示不正確的顏色,所以你既需要設(shè)置錯(cuò)誤提示為空,也需要讓下劃線的顏色恢復(fù)。同樣,如果你不斷地設(shè)置相同的錯(cuò)誤字符串,這個(gè)錯(cuò)誤提示會(huì)隨著動(dòng)畫不斷的閃爍,所以只有當(dāng)錯(cuò)誤提示有新的值時(shí)才要去重寫。
最后,當(dāng)焦點(diǎn)在 TextWatcher 內(nèi)的 EditText 上時(shí),我有一點(diǎn)點(diǎn)調(diào)皮的要求 ——當(dāng)你看到我是如何驗(yàn)證輸入表單的,希望你能明白我為什么這么做,但是對(duì)于你的需求,你可能想要把這段邏輯移到其他地方。
作為一個(gè)額外的優(yōu)化,我發(fā)現(xiàn)我可以在 onTextChanged 方法的 TextWatcher 接口內(nèi)實(shí)現(xiàn)我所有的邏輯,所以我給 beforeTextChanged 和 afterTextChanged 的父類增加了兩個(gè)空方法。
最小長(zhǎng)度驗(yàn)證
現(xiàn)在,讓我們這個(gè)類的一個(gè)具體的例子。一個(gè)常見的用例是輸入字段需要至少為 x 個(gè)的字符。因此,讓我們創(chuàng)建一個(gè) MinimumLengthTextWatcher。它帶有一個(gè)最小長(zhǎng)度值,當(dāng)然,在父類中,我還需要 TextInputLayout 和 message。此外,我不想在他們輸入完成之前一直告訴用戶他們需要輸入 x 個(gè)字符——這會(huì)是一個(gè)壞的用戶體驗(yàn)——所以我們應(yīng)該在用戶已經(jīng)超出了最小限制字符的時(shí)候來開始顯示錯(cuò)誤。(譯者注:可以理解為當(dāng)用戶輸入的長(zhǎng)度超過最小限制字符之后,用戶再刪除一部分字符,如果此時(shí)少于最小限制字符,就會(huì)顯示錯(cuò)誤了,這樣就能理解了)
public class MinimumLengthTextWatcher extends ErrorTextWatcher {
private final int mMinLength;
private boolean mReachedMinLength = false;
public MinimumLengthTextWatcher(final TextInputLayout textInputLayout, final int minLength) {
this(textInputLayout, minLength, R.string.error_too_few_characters);
}
public MinimumLengthTextWatcher(final TextInputLayout textInputLayout, final int minLength, @StringRes final int errorMessage) {
super(textInputLayout, String.format(textInputLayout.getContext().getString(errorMessage), minLength));
this.mMinLength = minLength;
}
這里有兩個(gè)構(gòu)造方法:一個(gè)是具有默認(rèn)的消息,還有一個(gè)是對(duì)于特殊的文本字段你可以創(chuàng)建一個(gè)更具體的值。因?yàn)槲覀兿胍С之?dāng)?shù)鼗?,我們采?Android string 資源文件,而不是硬編碼 String 的值。
我們文本的改變和驗(yàn)證方法現(xiàn)在已經(jīng)像下面這樣簡(jiǎn)單的實(shí)現(xiàn)了:
@Override
public void onTextChanged(final CharSequence text…) {
if (mReachedMinLength) {
validate();
}
if (text.length() >= mMinLength) {
mReachedMinLength = true;
}
}
@Override
public boolean validate() {
mReachedMinLength = true; // This may not be true but now we want to force the error to be shown
showError(getEditTextValue().length() < mMinLength);
return !hasError();
}
你會(huì)注意到,一旦驗(yàn)證方法在 TextWatcher 中被調(diào)起的話,它將會(huì)顯示錯(cuò)誤。我想這適用于大多數(shù)情況,但是你可能想要引入一個(gè) setter 方法去重置某些情況下的這種行為。
你現(xiàn)在需要去給你的 TextInputLayout 增加 TextWatcher,接著在你的 Activity 或 Fragment 中去創(chuàng)建 views。就像這樣:
mPasswordView = (TextInputLayout) findViewById(R.id.password_text_input_layout); mValidPasswordTextWatcher = new MinimumLengthTextWatcher(mPasswordView, getResources().getInteger(R.integer.min_length_password)); mPasswordView.getEditText().addTextChangedListener(mValidPasswordTextWatcher);
然后,在你代碼的合適位置,你可以檢查一個(gè)字段是否有效:
boolean isValid = mValidPasswordTextWatcher.validate();
如果密碼是無效的,這個(gè) View 會(huì)自動(dòng)的獲得焦點(diǎn)并將屏幕滾動(dòng)到這里。
驗(yàn)證電子郵件地址
另一種常見的驗(yàn)證用例是檢查電子郵件地址是否是有效的。我可以很容易的寫一整篇都關(guān)于用正則表達(dá)式來驗(yàn)證郵件地址的文章,但是因?yàn)檫@常常是有爭(zhēng)議的,我已經(jīng)從 TextWatcher 本身分開了郵件驗(yàn)證的邏輯。示例項(xiàng)目包含了可測(cè)試的 EmailAddressValidator,你可以用它,或者你也可以用你自己想要的邏輯來實(shí)現(xiàn)。
既然我已經(jīng)把郵件驗(yàn)證邏輯分離出來了,ValidEmailTextWatcher 是和 MinimumLengthTextWatcher 非常相似的。
public class ValidEmailTextWatcher extends ErrorTextWatcher {
private final EmailAddressValidator mValidator = new EmailAddressValidator();
private boolean mValidated = false;
public ValidEmailTextWatcher(@NonNull final TextInputLayout textInputLayout) {
this(textInputLayout, R.string.error_invalid_email);
}
public ValidEmailTextWatcher(@NonNull final TextInputLayout textInputLayout, @StringRes final int errorMessage) {
super(textInputLayout, textInputLayout.getContext().getString(errorMessage));
}
@Override
public void onTextChanged(…) {
if (mValidated) {
validate();
}
}
@Override
public boolean validate() {
showError(!mValidator.isValid(getEditTextValue()));
mValidated = true;
return !hasError();
}
這個(gè) TextWatcher 在我們的 Activity 或 Fragment 內(nèi)的實(shí)現(xiàn)方式是和之前的是非常像的:
mEmailView = (TextInputLayout) findViewById(R.id.email_text_input_layout); mValidEmailTextWatcher = new ValidEmailTextWatcher(mEmailView); mEmailView.getEditText().addTextChangedListener(mValidEmailTextWatcher);
把它放在一起
對(duì)于表單注冊(cè)或登錄,在提交給你的 API 之前,你通常會(huì)驗(yàn)證所有的字段。因?yàn)槲覀円箨P(guān)注在 TextWatcher 的任何 views 的失敗驗(yàn)證。我一般在從下往上驗(yàn)證所有的 view。這樣,應(yīng)用程序顯示所有需要糾正字段的錯(cuò)誤,然后跳轉(zhuǎn)到表單上第一個(gè)錯(cuò)誤輸入的文本。例如:
private boolean allFieldsAreValid() {
/**
* Since the text watchers automatically focus on erroneous fields, do them in reverse order so that the first one in the form gets focus
* &= may not be the easiest construct to decipher but it's a lot more concise. It just means that once it's false it doesn't get set to true
*/
boolean isValid = mValidPasswordTextWatcher.validate();
isValid &= mValidEmailTextWatcher.validate();
return isValid;
}
你可以找到上述所有代碼的例子在 GitHub[1] 上。這是一個(gè)在 ClearableEditText 上的分支,我是基于 讓你的 EditText 全部清除[2] 這篇博客上的代碼來進(jìn)行闡述的,但是把它用在標(biāo)準(zhǔn)的 EditText 上也是一樣的。它還包括了一些更多的技巧和 bug 處理,我沒有時(shí)間在這里提了。
盡管我只顯示了兩個(gè) TextWatcher 的例子,但我希望你能看到這是多么簡(jiǎn)單,你現(xiàn)在能添加其他的 TextWatcher 去給任何文本輸入添加不同的驗(yàn)證方法,并在你的 APP 中去請(qǐng)求驗(yàn)證和重用。
帶清除功能的輸入框控件ClearEditText
下面給大家?guī)硪粋€(gè)很實(shí)用的小控件ClearEditText,就是在Android系統(tǒng)的輸入框右邊加入一個(gè)小圖標(biāo),點(diǎn)擊小圖標(biāo)可以清除輸入框里面的內(nèi)容,IOS上面直接設(shè)置某個(gè)屬性就可以實(shí)現(xiàn)這一功能,但是Android原生EditText不具備此功能,所以要想實(shí)現(xiàn)這一功能我們需要重寫EditText,接下來就帶大家來實(shí)現(xiàn)這一小小的功能
我們知道,我們可以為我們的輸入框在上下左右設(shè)置圖片,所以我們可以利用屬性android:drawableRight設(shè)置我們的刪除小圖標(biāo),如圖

我這里設(shè)置了左邊和右邊的圖片,如果我們能為右邊的圖片設(shè)置監(jiān)聽,點(diǎn)擊右邊的圖片清除輸入框的內(nèi)容并隱藏刪除圖標(biāo),這樣子這個(gè)小功能就迎刃而解了,可是Android并沒有給允許我們給右邊小圖標(biāo)加監(jiān)聽的功能,這時(shí)候你是不是發(fā)現(xiàn)這條路走不通呢,其實(shí)不是,我們可能模擬點(diǎn)擊事件,用輸入框的的onTouchEvent()方法來模擬,
當(dāng)我們觸摸抬起(就是ACTION_UP的時(shí)候)的范圍 大于輸入框左側(cè)到清除圖標(biāo)左側(cè)的距離,小與輸入框左側(cè)到清除圖片右側(cè)的距離,我們則認(rèn)為是點(diǎn)擊清除圖片,當(dāng)然我這里沒有考慮豎直方向,只要給清除小圖標(biāo)就上了監(jiān)聽,其他的就都好處理了,我先把代碼貼上來,在講解下
package com.example.clearedittext;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnFocusChangeListener;
import android.view.animation.Animation;
import android.view.animation.CycleInterpolator;
import android.view.animation.TranslateAnimation;
import android.widget.EditText;
public class ClearEditText extends EditText implements
OnFocusChangeListener, TextWatcher {
/**
* 刪除按鈕的引用
*/
private Drawable mClearDrawable;
/**
* 控件是否有焦點(diǎn)
*/
private boolean hasFoucs;
public ClearEditText(Context context) {
this(context, null);
}
public ClearEditText(Context context, AttributeSet attrs) {
//這里構(gòu)造方法也很重要,不加這個(gè)很多屬性不能再XML里面定義
this(context, attrs, android.R.attr.editTextStyle);
}
public ClearEditText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
private void init() {
//獲取EditText的DrawableRight,假如沒有設(shè)置我們就使用默認(rèn)的圖片
mClearDrawable = getCompoundDrawables()[2];
if (mClearDrawable == null) {
// throw new NullPointerException("You can add drawableRight attribute in XML");
mClearDrawable = getResources().getDrawable(R.drawable.delete_selector);
}
mClearDrawable.setBounds(0, 0, mClearDrawable.getIntrinsicWidth(), mClearDrawable.getIntrinsicHeight());
//默認(rèn)設(shè)置隱藏圖標(biāo)
setClearIconVisible(false);
//設(shè)置焦點(diǎn)改變的監(jiān)聽
setOnFocusChangeListener(this);
//設(shè)置輸入框里面內(nèi)容發(fā)生改變的監(jiān)聽
addTextChangedListener(this);
}
/**
* 因?yàn)槲覀儾荒苤苯咏oEditText設(shè)置點(diǎn)擊事件,所以我們用記住我們按下的位置來模擬點(diǎn)擊事件
* 當(dāng)我們按下的位置 在 EditText的寬度 - 圖標(biāo)到控件右邊的間距 - 圖標(biāo)的寬度 和
* EditText的寬度 - 圖標(biāo)到控件右邊的間距之間我們就算點(diǎn)擊了圖標(biāo),豎直方向就沒有考慮
*/
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
if (getCompoundDrawables()[2] != null) {
boolean touchable = event.getX() > (getWidth() - getTotalPaddingRight())
&& (event.getX() < ((getWidth() - getPaddingRight())));
if (touchable) {
this.setText("");
}
}
}
return super.onTouchEvent(event);
}
/**
* 當(dāng)ClearEditText焦點(diǎn)發(fā)生變化的時(shí)候,判斷里面字符串長(zhǎng)度設(shè)置清除圖標(biāo)的顯示與隱藏
*/
@Override
public void onFocusChange(View v, boolean hasFocus) {
this.hasFoucs = hasFocus;
if (hasFocus) {
setClearIconVisible(getText().length() > 0);
} else {
setClearIconVisible(false);
}
}
/**
* 設(shè)置清除圖標(biāo)的顯示與隱藏,調(diào)用setCompoundDrawables為EditText繪制上去
* @param visible
*/
protected void setClearIconVisible(boolean visible) {
Drawable right = visible ? mClearDrawable : null;
setCompoundDrawables(getCompoundDrawables()[0],
getCompoundDrawables()[1], right, getCompoundDrawables()[3]);
}
/**
* 當(dāng)輸入框里面內(nèi)容發(fā)生變化的時(shí)候回調(diào)的方法
*/
@Override
public void onTextChanged(CharSequence s, int start, int count,
int after) {
if(hasFoucs){
setClearIconVisible(s.length() > 0);
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
/**
* 設(shè)置晃動(dòng)動(dòng)畫
*/
public void setShakeAnimation(){
this.setAnimation(shakeAnimation(5));
}
/**
* 晃動(dòng)動(dòng)畫
* @param counts 1秒鐘晃動(dòng)多少下
* @return
*/
public static Animation shakeAnimation(int counts){
Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
translateAnimation.setInterpolator(new CycleInterpolator(counts));
translateAnimation.setDuration(1000);
return translateAnimation;
}
}
setClearIconVisible()方法,設(shè)置隱藏和顯示清除圖標(biāo)的方法,我們這里不是調(diào)用setVisibility()方法,setVisibility()這個(gè)方法是針對(duì)View的,我們可以調(diào)用setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom)來設(shè)置上下左右的圖標(biāo)
setOnFocusChangeListener(this) 為輸入框設(shè)置焦點(diǎn)改變監(jiān)聽,如果輸入框有焦點(diǎn),我們判斷輸入框的值是否為空,為空就隱藏清除圖標(biāo),否則就顯示
addTextChangedListener(this) 為輸入框設(shè)置內(nèi)容改變監(jiān)聽,其實(shí)很簡(jiǎn)單呢,當(dāng)輸入框里面的內(nèi)容發(fā)生改變的時(shí)候,我們需要處理顯示和隱藏清除小圖標(biāo),里面的內(nèi)容長(zhǎng)度不為0我們就顯示,否是就隱藏,但這個(gè)需要輸入框有焦點(diǎn)我們才改變顯示或者隱藏,為什么要需要焦點(diǎn),比如我們一個(gè)登陸界面,我們保存了用戶名和密碼,在登陸界面onCreate()的時(shí)候,我們把我們保存的密碼顯示在用戶名輸入框和密碼輸入框里面,輸入框里面內(nèi)容發(fā)生改變,導(dǎo)致用戶名輸入框和密碼輸入框里面的清除小圖標(biāo)都顯示了,這顯然不是我們想要的效果,所以加了一個(gè)是否有焦點(diǎn)的判斷
setShakeAnimation(),這個(gè)方法是輸入框左右抖動(dòng)的方法,之前我在某個(gè)應(yīng)用看到過類似的功能,當(dāng)用戶名錯(cuò)誤,輸入框就在哪里抖動(dòng),感覺挺好玩的,其實(shí)主要是用到一個(gè)移動(dòng)動(dòng)畫,然后設(shè)置動(dòng)畫的變化率為正弦曲線
接下來我們來使用它,Activity的布局,兩個(gè)我們自定義的輸入框,一個(gè)按鈕
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#95CAE4">
<com.example.clearedittext.ClearEditText
android:id="@+id/username"
android:layout_marginTop="60dp"
android:layout_width="fill_parent"
android:background="@drawable/login_edittext_bg"
android:drawableLeft="@drawable/icon_user"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:singleLine="true"
android:drawableRight="@drawable/delete_selector"
android:hint="輸入用戶名"
android:layout_height="wrap_content" >
</com.example.clearedittext.ClearEditText>
<com.example.clearedittext.ClearEditText
android:id="@+id/password"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:drawableLeft="@drawable/account_icon"
android:hint="輸入密碼"
android:singleLine="true"
android:password="true"
android:drawableRight="@drawable/delete_selector"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/username"
android:background="@drawable/login_edittext_bg" >
</com.example.clearedittext.ClearEditText>
<Button
android:id="@+id/login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:background="@drawable/login_button_bg"
android:textSize="18sp"
android:textColor="@android:color/white"
android:layout_below="@+id/password"
android:layout_marginTop="25dp"
android:text="登錄" />
</RelativeLayout>
然后就是界面代碼的編寫,主要是測(cè)試輸入框左右晃動(dòng)而已,比較簡(jiǎn)單
package com.example.clearedittext;
import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
private Toast mToast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ClearEditText username = (ClearEditText) findViewById(R.id.username);
final ClearEditText password = (ClearEditText) findViewById(R.id.password);
((Button) findViewById(R.id.login)).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(TextUtils.isEmpty(username.getText())){
//設(shè)置晃動(dòng)
username.setShakeAnimation();
//設(shè)置提示
showToast("用戶名不能為空");
return;
}
if(TextUtils.isEmpty(password.getText())){
password.setShakeAnimation();
showToast("密碼不能為空");
return;
}
}
});
}
/**
* 顯示Toast消息
* @param msg
*/
private void showToast(String msg){
if(mToast == null){
mToast = Toast.makeText(this, msg, Toast.LENGTH_SHORT);
}else{
mToast.setText(msg);
}
mToast.show();
}
}
運(yùn)行項(xiàng)目,如圖,悲劇,沒有動(dòng)畫效果,算了就這樣子吧,你是不是也想把它加到你的項(xiàng)目當(dāng)中去呢,趕緊吧!

- android同時(shí)控制EditText輸入字符個(gè)數(shù)和禁止特殊字符輸入的方法
- Android文本輸入框(EditText)輸入密碼時(shí)顯示與隱藏
- Android之EditText控制禁止輸入空格和回車
- Android如何禁止向EditText控件中輸入內(nèi)容詳解
- Android UI設(shè)計(jì)系列之自定義EditText實(shí)現(xiàn)帶清除功能的輸入框(3)
- Android編程實(shí)現(xiàn)實(shí)時(shí)監(jiān)聽EditText文本輸入的方法
- Android輸入框控件ClearEditText實(shí)現(xiàn)清除功能
- Android高級(jí)xml布局之輸入框EditText設(shè)計(jì)
- Android EditText限制輸入字?jǐn)?shù)的方法
- Android中多個(gè)EditText輸入效果的解決方式
相關(guān)文章
Android okhttputils現(xiàn)在進(jìn)度顯示實(shí)例代碼
本文通過實(shí)例代碼給大家詳細(xì)介紹了Android okhttputils現(xiàn)在進(jìn)度顯示,代碼簡(jiǎn)答易懂,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧2016-12-12
Android自定義控件實(shí)現(xiàn)望遠(yuǎn)鏡效果
這篇文章主要為大家詳細(xì)介紹了Android自定義控件實(shí)現(xiàn)望遠(yuǎn)鏡效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-11-11
解決Android studio Error:(30, 31) 錯(cuò)誤: 程序包 不存在的問題
這篇文章主要介紹了解決Android studio Error:(30, 31) 錯(cuò)誤: 程序包 不存在的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-03-03
Android自定義View編寫隨機(jī)驗(yàn)證碼
這篇文章主要為大家詳細(xì)介紹了Android自定義View隨機(jī)驗(yàn)證碼實(shí)現(xiàn)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-10-10
Android 進(jìn)度條按鈕ProgressButton的實(shí)現(xiàn)代碼
這篇文章主要介紹了Android 進(jìn)度條按鈕實(shí)現(xiàn)(ProgressButton)代碼,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值 ,需要的朋友可以參考下2018-10-10
android 使用okhttp可能引發(fā)OOM的一個(gè)點(diǎn)
這篇文章主要介紹了android 使用okhttp可能引發(fā)OOM的一個(gè)點(diǎn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10
Android?Studio打包?aar實(shí)現(xiàn)步驟示例詳解
這篇文章主要為大家介紹了Android?Studio打包aar步驟示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-08-08
Android編程實(shí)現(xiàn)popupwindow定時(shí)消失的方法
這篇文章主要介紹了Android編程實(shí)現(xiàn)popupwindow定時(shí)消失的方法,結(jié)合實(shí)例形式分析了Android使用定時(shí)器實(shí)現(xiàn)popupwindow定時(shí)消失的相關(guān)操作技巧,需要的朋友可以參考下2018-01-01

