支付密码框
来源:互联网 发布:英制螺纹怎么编程 编辑:程序博客网 时间:2024/05/01 14:23
public class ShouquanMa_InputWidget extends LinearLayout {private static final int LENGTH = 6;private TextView[] password = new TextView[LENGTH];private EditText dymPassEdit;public InputCompeleListener oneditlistener = null;public ShouquanMa_InputWidget(Context context) {this(context, null);}public ShouquanMa_InputWidget(Context context, AttributeSet attrs) {super(context, attrs);initViews(context, attrs);}public void initViews(Context context, AttributeSet attrs) {LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);View view = inflater.inflate(R.layout.shouquanma_inputpass_widget, this, true);dymPassEdit = (EditText) view.findViewById(R.id.editpass);UnableEditTextCopyUtil.setEditHide_Copy_Paste_attr(dymPassEdit);password[0] = (TextView) view.findViewById(R.id.one);password[1] = (TextView) view.findViewById(R.id.two);password[2] = (TextView) view.findViewById(R.id.three);password[3] = (TextView) view.findViewById(R.id.four);password[4] = (TextView) view.findViewById(R.id.five);password[5] = (TextView) view.findViewById(R.id.six);dymPassEdit.requestFocus();Timer timer = new Timer();timer.schedule(new TimerTask() {public void run() {InputMethodManager imm = (InputMethodManager) dymPassEdit.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);}}, 998);OnClickListener listner = new OnClickListener() {@Overridepublic void onClick(View v) {InputMethodManager imm = (InputMethodManager) dymPassEdit.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);dymPassEdit.requestFocus();}};for (int i = 0; i < password.length; i++) {password[i].setOnClickListener(listner);}dymPassEdit.addTextChangedListener(new TextWatcher() {@Overridepublic void onTextChanged(CharSequence s, int start, int before, int count) {}@Overridepublic void beforeTextChanged(CharSequence s, int start, int count, int after) {}@Overridepublic void afterTextChanged(Editable s) {if (dymPassEdit.getText().length() == 6) {if (oneditlistener != null) {new Handler().postDelayed(new Runnable() {@Overridepublic void run() {oneditlistener.compeleteCallBack(true);}},150);}} else { oneditlistener.compeleteCallBack(false);}String text = dymPassEdit.getText().toString();for (int i = 0; i < 6; i++) {password[i].setText("");}for (int i = 0; i < text.length(); i++) {password[i].setText(".");}dymPassEdit.requestFocus();}});}public String getPassword() {return dymPassEdit.getText().toString();}public void setOnEditListenr(InputCompeleListener onEditListener) {if (onEditListener != null) {this.oneditlistener = onEditListener;}}/** * 回调:当已经输入六位数 */public interface InputCompeleListener {/** * */void compeleteCallBack(boolean b);} /** * 隐藏虚拟键盘 * @param v */ public void hideKeyboard() { InputMethodManager imm = ( InputMethodManager ) dymPassEdit.getContext( ).getSystemService( Context.INPUT_METHOD_SERVICE ); if ( imm.isActive( ) ) { imm.hideSoftInputFromWindow( dymPassEdit.getApplicationWindowToken( ) , 0 ); } } }
<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white"> <LinearLayout android:id="@+id/passlayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#ffffff" android:orientation="vertical"> <View style="@style/widget_horizontal_line_style" android:layout_height="1dip" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="48dp" android:layout_weight="1" android:orientation="horizontal" android:weightSum="6"> <View style="@style/widget_vertical_line_style" android:layout_width="1dip" android:layout_height="fill_parent" /> <TextView android:id="@+id/one" style="@style/widget_password_style" android:layout_gravity="center_vertical"/> <View style="@style/widget_vertical_line_style" /> <TextView android:id="@+id/two" style="@style/widget_password_style" /> <View style="@style/widget_vertical_line_style" /> <TextView android:id="@+id/three" style="@style/widget_password_style" /> <View style="@style/widget_vertical_line_style" /> <TextView android:id="@+id/four" style="@style/widget_password_style" /> <View style="@style/widget_vertical_line_style" /> <TextView android:id="@+id/five" style="@style/widget_password_style" /> <View style="@style/widget_vertical_line_style" /> <TextView android:id="@+id/six" style="@style/widget_password_style" /> <View style="@style/widget_vertical_line_style" android:layout_width="1dip" /> </LinearLayout> <View style="@style/widget_horizontal_line_style" android:layout_height="1dip" /> </LinearLayout> <EditText android:id="@+id/editpass" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@null" android:cursorVisible="false" android:inputType="numberPassword" android:maxLength="6" android:textColor="#ffffff" /></FrameLayout>
0 0
- 支付密码框
- 仿支付宝支付密码输入框
- 自定义view密码框等同于支付宝支付密码框
- THML输入支付密码框
- Android支付密码输入框
- 高仿微信支付的密码框
- 支付的密码输入框
- 仿微信支付密码输入框
- 自定义输入支付密码框
- GridPasswordView 类似支付宝支付密码输入框
- 微信支付宝支付密码输入框 PassWordEditView
- 仿支付宝支付密码输入框功能
- Android仿支付宝支付密码输入框
- Android仿支付宝支付密码输入框
- Android 仿支付宝支付密码输入框
- android 仿微信、支付宝支付密码框效果
- 自定义密码输入框(仿微信支付宝支付)
- android仿微信修改支付密码输入框
- 自定义折线统计图
- 文本框失去焦点实现更新
- 有关StringBuilder字符串的一些应用
- android调用系统文件浏览器获得uri或者文件路径
- 给Select标签赋值
- 支付密码框
- 锁屏清理进程
- 第一篇博客
- 在Servlet/JSP的学习中
- 对于Java的入门书籍
- jmap参数解释
- 公共技术点之 Android 动画基础
- watchDog数据库的操作
- hbase shell 常用命令