Custom progressdialog to improve user experience

Source: Internet
Author: User

Custom progressdialog to improve user experience
Custom progressdialog to improve user experience


:



Specific implementation methods:

1. Define the Layout of Dialog

2. Set the animation anim

3. Create a custom dialog Style

4. Create a common method to control the Dialog


<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + PHN0cm9uZz4xPC9zdHJvbmc + placement = "brush: java;">


2. Set the animation anim: Create the anim directory loading_animation.xml

 
     
  
 



3. Create a custom dialog style Theme: values directory themes. xml

     


4. Create a common method to control the Dialog

/*** Get the custom progressDialog * @ param context * @ return */public static Dialog createLoadingDialog (Context context) {LayoutInflater inflater = LayoutInflater. from (context); View v = inflater. inflate (R. layout. layout_loading_dialog, null); // obtain the value of loading view LinearLayout = (LinearLayout) v. findViewById (R. id. dialog_view); // load the layout ImageView spaceshipImage = (ImageView) v. findViewById (R. id. img); Animation hyperspaceJumpAnimation = AnimationUtils. loadAnimation (context, R. anim. loading_animation); // load the animation spaceshipImage. startAnimation (hyperspaceJumpAnimation); // use ImageView to display the animation Dialog loadingDialog = new Dialog (context, R. style. loading_dialog); // create a custom Style dialog // loadingDialog. setCancelable (false); // The "Return key" cannot be used to cancel loadingDialog. setContentView (layout, new LinearLayout. layoutParams (LinearLayout. layoutParams. WRAP_CONTENT, LinearLayout. layoutParams. WRAP_CONTENT); return loadingDialog ;}



OK! You can directly call it when using it: public Dialog mLoading; mLoading = DialogUtils. createLoadingDialog (this); mLoading. show (); mLoading. dismiss ();


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.