[Android] mobile guard custom dialog layout

Mobile phone anti-theft page

Click mobile phone anti-theft to judge. If no password is set, a dialog box for setting password will be displayed. If the password has been set, the dialog box for entering password will pop up

The password is saved in shared preferences, and the data is taken out for judgment

Customize a layout file, dialog_ setup_ password.xml

The root layout width should not fill the screen

The internal control should be smaller in width, leave space, and align in the center. Android: gravity = "center"

Two side-by-side buttons, OK and cancel, linear layout, horizontal orientation

Get the alertdialog. Builder object through new builder(). Parameter: context object

Call the setview (view) method of the builder object. Parameter: view object, which is filled through the layout filler

Call the view. Inflate (context, resource, root) method to convert the layout file into view object, context, resource, root

Call the show() method of the builder object

HomeActivity.java

dialog_ setup_ password.xml

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
分享
二维码
< <上一篇
下一篇>>