All Products
Search
Document Center

Numerical keyboard

Last Updated: May 25, 2021

AUNumberKeyboardView provides numeric keypads in three states.

Use the component

  • Use the component independently to show a view, for example, a mini program.
  • Bind the component with AUAmountEditText and use them together. The binding tool is AUNumberKeyBoardUtil, which is encapsulated in AUAmountEditText. For more information, see AUAmountInputBox documentation.
  • Bind the component with common EditText and use them together. The binding tool is AUNumberKeyBoardUtil, which needs to be called independently.

Sample images

Dependency

See Quick start.

API description

AUAmountEditText

 
  1. /**
  2. * Set the keyboard style. The default value is STYLE_POINT.
  3. * @param style STYLE_POINT, STYLE_X, and STYLE_NONE.
  4. */
  5. public void setStyle(int style)
  6. /**
  7. * Set button listening.
  8. * @param listener
  9. */
  10. public void setActionClickListener(OnActionClickListener listener)
  11. /**
  12. * Show status listening.
  13. * @param windowStateChangeListener
  14. */
  15. public void setWindowStateChangeListener(WindowStateChangeListener windowStateChangeListener)
  16. /**
  17. * Show.
  18. */
  19. public void show()
  20. /**
  21. * Hide.
  22. */
  23. public void hide()
  24. /**
  25. * Return the show state.
  26. * @return
  27. */
  28. public boolean isShow()

AUNumberKeyBoardUtil

 
  1. /**
  2. * Pass in EditText and AUNumberKeyboardView.
  3. * @param context
  4. * @param editText
  5. * @param keyboardView
  6. */
  7. public AUNumberKeyBoardUtil(Context context, EditText editText, AUNumberKeyboardView keyboardView)
  8. /**
  9. * Set the scroll view.
  10. * @param view
  11. */
  12. public void setScrollView(ScrollView view)
  13. /**
  14. * Show the numeric keypad.
  15. */
  16. public void showKeyboard()
  17. /**
  18. * Hide the numeric keypad.
  19. */
  20. public void hideKeyboard()

Sample code

AUAmountEditText

 
  1. AUNumberKeyboardView auNumberKeyboardView = new AUNumberKeyboardView(this, AUNumberKeyboardView.STYLE_POINT, new AUNumberKeyboardView.OnActionClickListener() {
  2. @Override
  3. public void onNumClick(View view, CharSequence num) {
  4. }
  5. @Override
  6. public void onDeleteClick(View view) {
  7. }
  8. @Override
  9. public void onConfirmClick(View view) {
  10. }
  11. @Override
  12. public void onCloseClick(View view) {
  13. }
  14. });

AUNumberKeyBoardUtil

  • XML
 
  1. <com.alipay.mobile.antui.basic.AULinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. android:layout_width="match_parent"
  3. android:layout_height="match_parent"
  4. android:orientation="vertical">
  5. <com.alipay.mobile.antui.basic.AUScrollView
  6. android:id="@+id/scroll"
  7. android:layout_weight="1"
  8. android:layout_width="match_parent"
  9. android:layout_height="match_parent">
  10. <com.alipay.mobile.antui.basic.AULinearLayout
  11. android:layout_width="match_parent"
  12. android:layout_height="match_parent"
  13. android:orientation="vertical">
  14. <EditText
  15. android:id="@+id/editText"
  16. android:layout_width="match_parent"
  17. android:layout_height="wrap_content"
  18. android:layout_marginTop="10dp" />
  19. </com.alipay.mobile.antui.basic.AULinearLayout>
  20. </com.alipay.mobile.antui.basic.AUScrollView>
  21. <com.alipay.mobile.antui.keyboard.AUNumberKeyboardView
  22. android:id="@+id/keyboard"
  23. android:layout_width="match_parent"
  24. android:layout_height="wrap_content"
  25. android:visibility="gone"/>
  26. </com.alipay.mobile.antui.basic.AULinearLayout>
  • Java
 
  1. keyBoardUtil = new AUNumberKeyBoardUtil(context, editText, keyboardView);
  2. keyBoardUtil.setScrollView(scrollView);