Load page Occlusion Time-consuming Operation task page--Androidprogresslayout_android of third party open source

Source: Internet
Author: User

The androidprogresslayout implementation adds a circular progress bar to the interface. Call the Setprogress () method to show and hide the progress bar

In the development of Android, there is often such a need, such as a time-consuming operation, networking to obtain network images, content, database time to read and write, and so on, during this time-consuming operation, the developer may not want the user to do other operations (other operations may cause logic confusion), At this point, you need to give the user an additional load page to block the operation of the main logic code, waiting for the main page of time-consuming operation after the completion of the automatic disappearance of this load over the page, restore the normal should be displayed page.

For example, if the code uses Android WebView to open a web link to try to load a Web site, but the quality of the network is not good enough to take a long time, then in this process, a better user experience approach is: to the User a Load Progress page, blocking the webview. When the loaded content is successful, it is completely switched back to the normal logical page.

The Android Androidprogresslayout implements this feature, and the Android Androidprogresslayout on GitHub's Project homepage is: Https://github.com/antonkrasov /androidprogresslayout

The test code is as follows:

Activity_main.xml:

 <com.github.androidprogresslayout.progresslayout xmlns:android= "Http://schemas.android.com/apk/res/android"
 xmlns:progresslayout= "Http://schemas.android.com/apk/res-auto"
 android:id= "@+id/progresslayout"
 Android:layout_width= "Match_parent"
 android:layout_height= "match_parent" >
 <textview
  android: Id= "@+id/textview"
  android:layout_width= "wrap_content"
  android:layout_height= "Wrap_content
  " Android:textsize= "sp"
  android:layout_centerinparent= "true"/>
 </ Com.github.androidprogresslayout.progresslayout>

Mainactivity.java:

Package com.zzw.testandroidprogresslayout;
 Import Com.github.androidprogresslayout.ProgressLayout;
 Import android.app.Activity;
 Import Android.os.Bundle;
 Import Android.os.Handler;
 Import Android.os.Message;
 Import android.view.animation.Animation;
 Import Android.widget.TextView; public class Mainactivity extends activity {@Override protected void onCreate (Bundle savedinstancestate) {SUPER.ONCR
  Eate (savedinstancestate);
  Setcontentview (R.layout.activity_main);
  Final Progresslayout progresslayout = (progresslayout) Findviewbyid (r.id.progresslayout);
  Final TextView TextView = (TextView) Findviewbyid (R.id.textview);
   Handler Handler = new Handler () {@Override public void Handlemessage (msg) {Textview.settext ("test completed");
  Switch back to the normal display page progresslayout.showcontent ();
  }
  }; Start loading ...
  Let's say that starting from here a time-consuming operation will start, in this startup process, developers want users to take a break, wait ...
  Progresslayout.showprogress ();
  Suppose there is a time-consuming load business logic that takes a second to complete.
 Handler.sendemptymessagedelayed (,); }
 }

The above content is small to share on the loading page to cover the time-consuming operation of the task page-the third party open source androidprogresslayout all the narrative, I hope you like.

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.