仿支付寶密碼支付頁 + 自定義數(shù)字鍵盤 + 身份證鍵盤

KeyboardInputDemo

這是一個(gè)仿支付寶自定義軟鍵盤的demo,分別為身份證號(hào)碼、支付金額、支付密碼輸入定制的軟鍵盤,以及EditText文本輸入框與密碼輸入框的定制。

先上效果圖:  
image.png
圖片發(fā)自簡書App
圖片發(fā)自簡書App
圖片發(fā)自簡書App

一 身份證鍵盤
1 身份證鍵盤在MainActivity頁面,使用時(shí)再布局中添加配置

<com.example.weioule.inputkeyboarddemo.view.CEditText
    android:id="@+id/indentity_card"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:clear="true"
    app:hit="請(qǐng)輸入身份證號(hào)"
    app:input_typed="email"
    app:left_text="身份證號(hào)"
    app:length="18"
    app:show_bottom_split="false"
    app:show_custom_keyboard="true"
    tools:layout_height="60dp" />

要使用自定義的鍵盤記得配置:app:show_custom_keyboard="true"

2 在Activity中創(chuàng)建 CumKeyboardContainer:

mCustomKeyboardView = new CumKeyboardContainer(this, getInputType());
mCustomKeyboardView.attachKeyBoardView();

3 并為輸入框CEditText配置

mIndentityCard = findViewById(R.id.indentity_card);
mIndentityCard.setCustomKeyboardView(mCustomKeyboardView);

4 在onBackPressed中配置回退鍵盤,若鍵盤顯示則先隱藏

 if (mCustomKeyboardView != null && mCustomKeyboardView.getVisibility() == View.VISIBLE) {
      mCustomKeyboardView.setCmbVisibility(View.GONE);
  }

二 數(shù)字鍵盤
數(shù)字鍵盤在SecondActivity頁面,使用方法同上,只是在第二步中修改類型為金額輸入:

 mCustomKeyboardView = new CumKeyboardContainer(this, CumKeyboardContainer.AMOUT_TYPE);

三 支付密碼對(duì)話框
1 創(chuàng)建輸入框和回調(diào)方法

 inputPayPwdDialog = new InputPayPwdDialog(this);
    inputPayPwdDialog.setInputPasswordListener(new InputPayPwdDialog.PasswordListener() {
        @Override
        public void onSubmitPwd(String password) {
            Toast.makeText(SecondActivity.this, "成功支付" + mIndentityCard.getText() + "元", Toast.LENGTH_SHORT).show();
        }
    });

2 在顯示的時(shí)候調(diào)用

 inputPayPwdDialog.show();

3 獲取密碼

 inputPayPwdDialog.getPassword();



項(xiàng)目地址:https://github.com/weioule/KeyboardInputDemo

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容