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