数字键盘

AUNumberKeyboardView 提供三种状态的数字键盘。

使用说明

  • 单独作为一个视图展示,如小程序。

  • 与 AUAmountEditText 绑定使用,绑定工具为 AUNumberKeyBoardUtil,已经封装入 AUAmountEditText,具体可参考 AUAmountInputBox 文档

  • 与普通的 Edittext 绑定使用,绑定工具为 AUNumberKeyBoardUtil,需自行调用。

效果图

依赖

参见 管理组件依赖

接口说明

AUAmountEditText

    /**
     * 设置键盘的样式,默认为 STYLE_POINT
     * @param style STYLE_POINT、STYLE_X、STYLE_NONE
     */
    public void setStyle(int style)

    /**
     * 设置按钮监听
     * @param listener
     */
    public void setActionClickListener(OnActionClickListener listener)

    /**
     * 设置展示状态监听
     * @param windowStateChangeListener
     */
    public void setWindowStateChangeListener(WindowStateChangeListener windowStateChangeListener)

    /**
     * 展示
     */
    public void show()

    /**
     * 消失
     */
    public void hide()

    /**
     * 返回展示状态
     * @return
     */
    public boolean isShow()

AUNumberKeyBoardUtil

    /**
     * 传递入 EditText 以及 AUNumberKeyboardView
     * @param context
     * @param editText
     * @param keyboardView
     */
    public AUNumberKeyBoardUtil(Context context, EditText editText, AUNumberKeyboardView keyboardView)

    /**
     * 设置滚动 view
     * @param view
     */
    public void setScrollView(ScrollView view)

    /**
     * 显示数字键盘
     */
    public void showKeyboard() 

    /**
     * 隐藏数字键盘
     */
    public void hideKeyboard()

代码示例

AUAmountEditText

AUNumberKeyboardView  auNumberKeyboardView = new AUNumberKeyboardView(this, AUNumberKeyboardView.STYLE_POINT, new AUNumberKeyboardView.OnActionClickListener() {
            @Override
            public void onNumClick(View view, CharSequence num) {

            }

            @Override
            public void onDeleteClick(View view) {

            }

            @Override
            public void onConfirmClick(View view) {

            }

            @Override
            public void onCloseClick(View view) {

            }
        });

AUNumberKeyBoardUtil

  • XML:

    <com.alipay.mobile.antui.basic.AULinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical">
    
      <com.alipay.mobile.antui.basic.AUScrollView
          android:id="@+id/scroll"
          android:layout_weight="1"
          android:layout_width="match_parent"
          android:layout_height="match_parent">
    
          <com.alipay.mobile.antui.basic.AULinearLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical">
    
              <EditText
                  android:id="@+id/editText"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="10dp" />
          </com.alipay.mobile.antui.basic.AULinearLayout>
      </com.alipay.mobile.antui.basic.AUScrollView>
    
      <com.alipay.mobile.antui.keyboard.AUNumberKeyboardView
          android:id="@+id/keyboard"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:visibility="gone"/>
    </com.alipay.mobile.antui.basic.AULinearLayout>
  • Java:

    keyBoardUtil = new AUNumberKeyBoardUtil(context, editText, keyboardView);
    keyBoardUtil.setScrollView(scrollView);
阿里云首页 移动开发平台 mPaaS 相关技术圈