Ui details of mobile security guard for Android projects (the most complete code and the most detailed comments)

Source: Internet
Author: User

By convention, I wrote it above: maybe in the process of learning Android, everyone will learn a lot of basic knowledge like me, and a lot of knowledge points can also be said 123, however, these isolated points are too fragmented after all. Therefore, I want to take the most classic mobile security guard project as an example from today and exercise on my own. I also want to communicate with you, I hope everyone can give insights and make progress together. 8. process some small details on the interface. 1. If the dialog box appears and the user clicks back, it will stay on the splash interface. We need to click back to enter the main interface. This requires an OnCancleListener listener when canceling the dialog box. Put the code before show () in the dialog box.

Code:/** when the dialog box is canceled, go directly to the main interface */builder. setOnCancelListener (new OnCancelListener () {@ Override public void onCancel (DialogInterface dialog) {loadMainUI ();}});

 

2. after the new version is downloaded, a dialog box Indicating whether to install the new application is displayed. If you do not want to install the new version at this time, click Cancel and the new version is stuck on the splash interface. In this case, we need to get the returned value after the download is successful. You can use startActivityForResult (intent, 0) (shortcut key: Alt +/quick api acquisition) to convert apkInstall (File t) in the method, change startActivity (intent) to startActivityForResult (intent, 0), and then write the onActivityResult method. Code:
@Override  protected void onActivityResult(int requestCode, int resultCode, Intent data) {      loadMainUI();                 super.onActivityResult(requestCode, resultCode, data);  }  

 

3. The update reminder dialog box looks ugly. We want to make it more beautiful. How can this problem be solved? This style is displayed because the current activity theme style is of the old version: android: Theme = "@ android: style/theme. black. noTitleBar "At this time, we only need to delete this line of code to make the dialog box beautiful. However, the title bar appears again. We can use the code to remove the title bar. Then add the code requestWindowFeature (Window. FEATURE_NO_TITLE) under onCreate. Note: This sentence must be placed before setContentView; otherwise, an error occurs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.