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