Android development-custom rounded rectangle progress dialog box

Source: Internet
Author: User

Android development-custom rounded rectangle progress dialog box

Method 1: Custom dialog box

Public class ProgersssDialog extends Dialog {private ImageView img; private TextView txt; public ProgersssDialog (Context context) {super (context, R. style. progress_dialog); // load the layout file View = view. inflate (context, R. layout. progress_dialog, null); img = (ImageView) view. findViewById (R. id. progress_dialog_img); txt = (TextView) view. findViewById (R. id. progress_dialog_txt); // Add the Animation anim = AnimationUtils to the image. loadAnimation (context, R. anim. loading_dialog_progressbar); img. setAnimation (anim); txt. setText ("the data is being processed. Please wait... "); getWindow (). setBackgroundDrawableResource (R. drawable. round_retangle); // Add the setContentView (view); this. setCancelable (false);}/*** dialog box setting content * @ param msg */public void setMsg (String msg) {txt. setText (msg);}/*** Setting Dialog Box background * @ param msgId */public void setMsg (int msgId) {txt. setText (msgId);}/*** display dialog box */public void showProgersssDialog () {this. show ();}/*** close dialog box */public void closeProgersssDialog () {this. dismiss ();}}

Corresponding xml layout:

 
     
      
  
 

Corresponding style:

   




Method 2: implement with activity

1. directly use an activty layout and operate the activity instance in another activity. To start an activity in a non-activity instance, you must add intent. addFlags (Intent. FLAG_ACTIVITY_NEW_TASK );

public class LoadingActivity extends Activity{public static LoadingActivity mInstance=null;@Overridepublic void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.loading);mInstance=this;   }}

Corresponding rounded rectangle layout:

       
          
                           
                  
            
       
  
 

The effect is as follows:


Corresponding style:

 

The configuration in the configuration file is as follows:

               


2. Another layout implemented by activity: add the layout to the activity of the subject of a dialog box:

Layout:

 
     
       
            
          
                   
     
 

Effect:


Files in the drawable directory:

   
         
         
      
        
      
   

Http://download.csdn.net/detail/u014600432/8362247 Resources







Related Article

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.