Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Al click del pulsante
- public void onClick1(View view){
- Log.d("tag","onClick1 è stato aperto");
- new ProgressDialogTask().execute();
- }
- //ProgressDialogTask
- private class ProgressDialogTask extends AsyncTask<Void, Void, Void>{
- private ProgressDialog dialog;
- ProgressDialogTask(){
- dialog = new ProgressDialog(getBaseContext());
- }
- protected void onPreExecute() {
- dialog.setMax(100);
- dialog.setProgress(0);
- dialog.setTitle("Doing Something");
- dialog.setMessage("Please wait!");
- dialog.setCancelable(false);
- dialog.setIndeterminate(true);
- dialog.show();
- }
- @Override
- protected Void doInBackground(Void... params) {
- while(dialog.getProgress() <= dialog.getMax()){
- try{
- Thread.sleep(5000);
- }catch(Exception e){
- e.printStackTrace();
- }
- dialog.incrementProgressBy(5);
- }
- return null;
- }
- @Override
- protected void onPostExecute(Void v){
- dialog.dismiss();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement