国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

android:登錄界面,輸入框輸入數(shù)量達(dá)到了之后自動(dòng)隱藏鍵盤。

這篇具有很好參考價(jià)值的文章主要介紹了android:登錄界面,輸入框輸入數(shù)量達(dá)到了之后自動(dòng)隱藏鍵盤。。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

一、前言:這篇文章是關(guān)于當(dāng)我們輸入賬號(hào)密碼時(shí),達(dá)到11位(自定義)時(shí),自動(dòng)隱藏鍵盤。

二、上代碼:

界面布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <RadioGroup
        android:id="@+id/rg_login"
        android:layout_width="match_parent"
        android:layout_height="@dimen/item_layout_height"
        android:orientation="horizontal">

        <RadioButton
            android:id="@+id/rb_password"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:checked="true"
            android:text="@string/login_by_password"
            android:textSize="@dimen/common_font_size" />

        <RadioButton
            android:id="@+id/rb_verifycode"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="@string/login_by_verifycode"
            android:textSize="@dimen/common_font_size" />

    </RadioGroup>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="@dimen/item_layout_height"
        android:orientation="horizontal">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:gravity="center"
            android:text="@string/phone_number"
            android:textColor="@color/black"
            android:textSize="@dimen/common_font_size" />

        <EditText
            android:id="@+id/et_phone"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_marginTop="5dp"
            android:layout_marginBottom="5dp"
            android:layout_weight="1"
            android:inputType="number"
            android:hint="@string/input_phone_number"
            android:maxLength="11"
            android:textColorHint="@color/gray"
            android:textSize="@dimen/common_font_size" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="@dimen/item_layout_height"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/tv_password"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:gravity="center"
            android:text="@string/login_password"
            android:textColor="@color/black"
            android:textSize="@dimen/common_font_size" />

        <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1">

            <EditText
                android:id="@+id/et_password"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="5dp"
                android:layout_marginBottom="5dp"
                android:layout_weight="1"
                android:hint="@string/input_password"
                android:inputType="numberPassword"
                android:maxLength="11"
                android:textColorHint="@color/gray"
                android:textSize="@dimen/common_font_size" />

            <Button
                android:id="@+id/btn_forget"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_alignParentEnd="true"
                android:text="@string/foget_password"
                android:textColor="@color/black"
                android:textSize="@dimen/common_font_size" />
        </RelativeLayout>
    </LinearLayout>

    <CheckBox
        android:id="@+id/ck_remember"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/remember_password"
        android:textColor="@color/black"
        android:textSize="@dimen/common_font_size" />

    <Button
        android:id="@+id/btn_login"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/login"
        android:textSize="@dimen/buttom_font_size" />

</LinearLayout>

對(duì)應(yīng)的Activity:LoginMainActivity

public class LoginMainActivity extends AppCompatActivity implements RadioGroup.OnCheckedChangeListener {

    private TextView tv_password;
    private EditText et_password;
    private Button btn_forget;
    private CheckBox ck_remember;
    private EditText et_phone;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login_main);
        RadioGroup rg_login = findViewById(R.id.rg_login);
        tv_password = findViewById(R.id.tv_password);
        et_phone = findViewById(R.id.et_phone);
        et_password = findViewById(R.id.et_password);
        btn_forget = findViewById(R.id.btn_forget);
        ck_remember = findViewById(R.id.ck_remember);
        //給rg_login設(shè)置單選監(jiān)聽器
        rg_login.setOnCheckedChangeListener(this);
        //給et_phone添加文本變更器
        et_phone.addTextChangedListener(new HideTextWatcher(et_phone,11));
        //給et_password添加文本變更器
        et_password.addTextChangedListener(new HideTextWatcher(et_password,6));
    }

    @Override
    public void onCheckedChanged(RadioGroup radioGroup, int i) {
        switch (i){
            //選擇密碼登錄
            case R.id.rb_password:
                tv_password.setText(getString(R.string.login_password));
                et_password.setHint(getString(R.string.input_password));
                btn_forget.setText(getString(R.string.foget_password));
                ck_remember.setVisibility(View.VISIBLE);
                break;
                //選擇驗(yàn)證碼登錄
            case R.id.rb_verifycode:
                tv_password.setText(getString(R.string.verifycode));
                et_password.setHint(getString(R.string.input_verifycode));
                btn_forget.setText(getString(R.string.get_verifycode));
                ck_remember.setVisibility(View.GONE);
                break;
        }
    }

    //定義一個(gè)編輯框監(jiān)聽器,在輸入文本達(dá)到指定長(zhǎng)度時(shí)自動(dòng)隱藏輸入法
    private class HideTextWatcher implements TextWatcher {
        private  EditText mView;
        private int mMaxLength;
        public HideTextWatcher(EditText v, int maxLength) {
            this.mView = v;
            this.mMaxLength = maxLength;

        }

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        //在編輯框的輸入文本變化后觸發(fā)
        @Override
        public void afterTextChanged(Editable s) {
          //獲得已輸入的文本字符串
            String str = s.toString();
            if (str.length() == mMaxLength){
                //隱藏輸入法軟鍵盤
                ViewUtil.hideOneInputMethod(LoginMainActivity.this,mView);
            }
        }
    }
}

新建一個(gè)工具類:ViewUtil文章來源地址http://www.zghlxwxcb.cn/news/detail-529456.html

public class ViewUtil {
    public static void hideOneInputMethod(Activity act, View v){
        //從系統(tǒng)服務(wù)中獲取輸入法管理器
        InputMethodManager imm = (InputMethodManager) act.getSystemService(Context.INPUT_METHOD_SERVICE);
        //關(guān)閉屏幕上的輸入法軟鍵盤
        imm.hideSoftInputFromWindow(v.getWindowToken(),0);
    }
}

到了這里,關(guān)于android:登錄界面,輸入框輸入數(shù)量達(dá)到了之后自動(dòng)隱藏鍵盤。的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 中國(guó)汽車協(xié)會(huì):我國(guó)整車出口數(shù)量達(dá)到43.8萬輛,同比增長(zhǎng)92.8%

    中國(guó)汽車協(xié)會(huì):我國(guó)整車出口數(shù)量達(dá)到43.8萬輛,同比增長(zhǎng)92.8%

    根據(jù)中國(guó)汽車工業(yè)協(xié)會(huì)發(fā)布的數(shù)據(jù),今年5月份我國(guó)汽車整車出口量達(dá)到43.8萬輛,較上月增長(zhǎng)3.2%,同比增長(zhǎng)92.8%。 同時(shí),整車出口金額環(huán)比增長(zhǎng)8.8%,同比增長(zhǎng)1.2倍。而今年1-5月,汽車整車出口量達(dá)到193.3萬輛,同比增長(zhǎng)79.8%;整車出口金額同比增長(zhǎng)1.2倍。 在我國(guó)汽車出口市場(chǎng)

    2024年02月12日
    瀏覽(16)
  • 在unity里面雙擊腳本文件,系統(tǒng)自動(dòng)打開vs之后,界面上沒有“解決方案資源管理器”

    在unity里面雙擊腳本文件,系統(tǒng)自動(dòng)打開vs之后,界面上沒有“解決方案資源管理器”

    在unity里面雙擊腳本文件,系統(tǒng)自動(dòng)打開vs之后,界面上沒有“解決方案資源管理器”,寫部分代碼的時(shí)候也沒有提示。然后在視圖里把“解決方案資源管理器”調(diào)出來之后上面也不顯示這個(gè)項(xiàng)目 解決方法: 檢查一下Unity 和 Visual Studio 有沒有關(guān)聯(lián) 1、打開 Unity項(xiàng)目 2、選擇頂部

    2024年02月05日
    瀏覽(36)
  • Android實(shí)現(xiàn)簡(jiǎn)單的登錄界面

    該登錄界面一共實(shí)現(xiàn)三個(gè)功能: 1.實(shí)現(xiàn)登錄 2.實(shí)現(xiàn)注冊(cè) 3.實(shí)現(xiàn)記住密碼 AndroidManifest.xml 文件: bean文件中的Account類: ?db文件夾中的AccountService: db文件夾中的DataBaseHelper: MainActivity: ?loginActivity registeredActivity layout文件中的activity_main layout中的login文件 layout文件中的registere

    2023年04月16日
    瀏覽(20)
  • Android Studio——實(shí)現(xiàn)登錄界面

    Android Studio——實(shí)現(xiàn)登錄界面 在移動(dòng)應(yīng)用開發(fā)中,登錄界面是一種常見的設(shè)計(jì)需求。通過使用Android Studio,我們可以輕松實(shí)現(xiàn)一個(gè)簡(jiǎn)單且美觀的登錄界面。本文將介紹如何使用Android Studio創(chuàng)建一個(gè)登錄界面,并提供相應(yīng)的源代碼。 步驟1:創(chuàng)建新項(xiàng)目 首先,打開Android Studio并創(chuàng)

    2024年02月08日
    瀏覽(19)
  • Android Studio制作簡(jiǎn)單登錄界面

    Android Studio制作簡(jiǎn)單登錄界面

    應(yīng)用線性布局設(shè)計(jì)登錄界面,要求點(diǎn)擊輸入學(xué)號(hào)時(shí)彈出數(shù)字鍵盤界面,點(diǎn)擊輸入密碼時(shí)彈出字母鍵盤,出現(xiàn)的文字、數(shù)字、尺寸等全部在values文件夾下相應(yīng).xml文件中設(shè)置好,使用時(shí)直接引用。當(dāng)用戶名或密碼為空,顯示一個(gè)提示信息“用戶名與密碼不能為空!”,當(dāng)用戶名和

    2024年04月15日
    瀏覽(24)
  • elementUi upload上傳達(dá)到limit后隱藏upload圖標(biāo)

    如題所述,我們項(xiàng)目要求上傳控件最大只允許上傳3張。當(dāng)數(shù)量達(dá)到的時(shí)候,自動(dòng)隱藏上傳按鈕控件。而當(dāng)點(diǎn)擊刪除之前的照片后,又重新顯示上傳按鈕控件。 這里我們選用了餓了么的elementUi里的el-upload控件作為基礎(chǔ),再添加我們的需求。 主要的templete如下 而對(duì)應(yīng)的style如下

    2024年02月16日
    瀏覽(26)
  • Android學(xué)習(xí)(一)--用戶登錄注冊(cè)界面(界面跳轉(zhuǎn)+背景音樂)

    Android學(xué)習(xí)(一)--用戶登錄注冊(cè)界面(界面跳轉(zhuǎn)+背景音樂)

    目錄 1.功能要求 2.功能實(shí)現(xiàn)流程圖 3.功能演示 4.界面與功能 ?4.1登錄界面 4.1.1界面展示 4.1.2登錄界面功能簡(jiǎn)介 4.1.3界面代碼 4.1.4登錄按鈕點(diǎn)擊事件 4.1.5退出按鈕點(diǎn)擊事件 ?4.1.6背景音樂點(diǎn)擊事件 4.1.7記住密碼 5.Java源碼 (1)三個(gè)界面布局,體現(xiàn)文本框、編輯框、單選按鈕、復(fù)

    2024年02月05日
    瀏覽(21)
  • Android studio編寫一個(gè)簡(jiǎn)單的登錄界面

    Android studio編寫一個(gè)簡(jiǎn)單的登錄界面

    1首先先創(chuàng)建一個(gè)空的activity項(xiàng)目,接著設(shè)置自己的項(xiàng)目名稱,勾選上lacuncher 創(chuàng)建成功后點(diǎn)開 manifests 把剛剛創(chuàng)建的文件名下面的 intent-filter 這一行全部刪除 然后點(diǎn)開res,復(fù)制一張圖片,右鍵drawable點(diǎn)擊粘貼,這里放的是圖片資源,用于放置登錄頭像 然后點(diǎn)開layout文件,開始編

    2024年04月15日
    瀏覽(23)
  • 【Selenium+python】自動(dòng)化測(cè)試登錄界面

    【Selenium+python】自動(dòng)化測(cè)試登錄界面

    前言:已經(jīng)學(xué)習(xí)selenium許久了,奈何公司的項(xiàng)目還在碼代碼中...,感覺自己學(xué)的東西快忘的差不多了,所以就找個(gè)網(wǎng)站練練手,順便回顧一下UI自動(dòng)化的知識(shí),也希望跟我一樣的小白有所受益。 用例1: 正確輸入手機(jī)號(hào)和密碼,點(diǎn)擊登錄 期望:有幫助中心字樣(系統(tǒng)跳至首頁

    2024年02月08日
    瀏覽(24)
  • 用Android Studio編寫一個(gè)登錄界面和注冊(cè)界面并可以跳轉(zhuǎn)

    下面是使用 Android Studio 編寫一個(gè)簡(jiǎn)單的登錄界面和注冊(cè)界面,并實(shí)現(xiàn)跳轉(zhuǎn)的示例代碼。 首先,在 res/layout 目錄下創(chuàng)建一個(gè)名為 activity_login.xml 的布局文件,作為登錄界面的布局: 接下來,在 res/layout 目錄下創(chuàng)建一個(gè)名為 activity_register.xml 的布局文件,作為注冊(cè)界面的布局:

    2024年04月09日
    瀏覽(33)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包