Android implements Alipay 6 bit password input interface

Let's analyze according to the picture: (1) limit the input of 6 bits, each bit has its own frame, and each frame displays one bit; (2) There is a back / cancel payment button; (3) There is a link to forget your password; (4) User defined keyboard input area that can only input numbers; (5) After 6 bits are input, password verification and payment transaction will be carried out automatically. For example, on the left side of the picture is the iOS Alipay payment password entry control, and on the right is my imitation effect.

First, we need a page to complete the above static layout. The. XML code is as follows:

Where fillet background shape is required_ input_ area.xml:

Background selector requiring numeric buttons_ gride.xml:

Back key background selector required_ key_ del.xml:

Let's complete our custom control passwordview.java:

I think code comments are OK. That is, pay attention to the out of bounds of the array in the implementation process, and pay attention to the logic processing in the input logic response, that is, the onitemclicklistener event processing of GridView. The user-defined interface onpasswordinputfinish is used to return the input completed event:

There is also the layout item of each button item used in the adapter_ gride.xml:

OK, here's our custom control -- the imitation of Alipay's 6 bit password entry control. We'll use it in Activity to test the effect: we use the controls that we define in MianActivity:

In the first method, we use the layout file:

For more information, please refer to the topic: Android password tutorial

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>