zoukankan      html  css  js  c++  java
  • [Android]放微信支付宝输入框

    网上搜索资料后,找到两种比较好的方法,总结如下

    方法一:通过自定义view实现

    1.1自定义view

    
    
    public class InputPasswordActivity extends CtmCashActivity implements PassswordInputView.InputCallBack {
        private PassswordInputView mPasswordView;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_input_password);
            mPasswordView = (PassswordInputView) findViewById(R.id.text_password);
            mPasswordView.setInputCallBack(this);
        }
    
        @Override
        public void onInputFinish(String result) {
            Toast.makeText(this, result, Toast.LENGTH_LONG).show();
        }
    }

    1.2.布局

    <?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"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
        <com.ctm.ctmcash.view.PassswordInputView
            android:id="@+id/text_password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:layout_marginTop="40dp"
            android:background="@android:color/white"
            app:border_color="@color/password_box_gray"
            app:dot_color="@color/text_dark_gray"></com.ctm.ctmcash.view.PassswordInputView>
    </LinearLayout>

    1.3.测试activity

    public class InputPasswordActivity extends CtmCashActivity implements PassswordInputView.InputCallBack {
        private PassswordInputView mPasswordView;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_input_password);
            mPasswordView = (PassswordInputView) findViewById(R.id.text_password);
            mPasswordView.setInputCallBack(this);
        }
    
        @Override
        public void onInputFinish(String result) {
            Toast.makeText(this, result, Toast.LENGTH_LONG).show();
        }
    }

    1.4.显示效果如下

     

    方法二.利用https://github.com/Jungerr/GridPasswordView

  • 相关阅读:
    数据库回滚解决删除数据库出错
    教大家支付宝抢红包
    MySql 连接字符串
    搭建Git服务器
    队列的顺序存储结构
    栈的应用---递归
    栈的链式存储结构及应用(C、Java代码)
    栈的顺序存储结构及应用(C、Java代码)
    静态链表、循环链表、双向链表(C代码实现)
    线性表的链式存储结构(Java代码实现)
  • 原文地址:https://www.cnblogs.com/ryq2014/p/6800508.html
Copyright © 2011-2022 走看看