Custom progressdialog to load the animation. Here there are also rotating loading entries, Meituan, and multiple image animations,

Source: Internet
Author: User

Custom progressdialog to load the animation. Here there are also rotating loading entries, Meituan, and multiple image animations,

Custom progressdialog to load the animation. Here there are also rotating loading entries, Meituan, and multiple image animations.

Download Demo: http://download.csdn.net/detail/menglele1314/8775497


Public class MainActivity extends Activity {

Private Button submit;

Private AnimationDrawable fightnimation, fightnimationab;
Private ImageView pb, net, netab;
Private Dialog mLoading;
Private Animation animation;

@ Override
Protected void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
RequestWindowFeature (Window. FEATURE_NO_TITLE );
SetContentView (R. layout. activity_main );

Submit = (Button) findViewById (R. id. btn_login_submit );

Pb = (ImageView) findViewById (R. id. iv_failure );
Animation = AnimationUtils. loadAnimation (MainActivity. this,
R. anim. cirle );
Animation. setInterpolator (new LinearInterpolator ());

Netab = (ImageView) findViewById (R. id. iv_netab );
Netab. setBackgroundResource (R. anim. fight );
Fightnimationab = (AnimationDrawable) netab. getBackground ();

Net = (ImageView) findViewById (R. id. iv_net );
Net. setBackgroundResource (R. anim. loading );
Fightnimation = (AnimationDrawable) net. getBackground ();

Submit. setOnClickListener (new OnClickListener (){

@ Override
Public void onClick (View arg0 ){
MLoading = createLoadingDialog (MainActivity. this );
MLoading. show ();
// MLoading. dismiss ();

Pb. startAnimation (animation );
Fightnimationab. start ();
Fightnimation. start ();

}
});
}

/**
* 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 loaded view
LinearLayout layout = (LinearLayout) v. findViewById (R. id. dialog_view); // load the layout
ImageView spaceshipImage = (ImageView) v. findViewById (R. id. img );
Animation animation = AnimationUtils. loadAnimation (
Context, R. anim. cirle); // load the animation
Animation. setInterpolator (new LinearInterpolator ());
SpaceshipImage. startAnimation (animation); // use ImageView to display the animation
Dialog loadingDialog = new Dialog (context, R. style. loading_dialog); // create a custom style dialog

// LoadingDialog. setCancelable (false); // you cannot use the "Return key" to cancel the operation.
LoadingDialog. setContentView (layout, new LinearLayout. LayoutParams (
LinearLayout. LayoutParams. WRAP_CONTENT,
LinearLayout. LayoutParams. WRAP_CONTENT ));
Return loadingDialog;
}
}

Download Demo: Click the open link

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.