Created
August 22, 2012 11:55
-
-
Save kojiokb/3424835 to your computer and use it in GitHub Desktop.
2.2のぐるぐるしない対策
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends Activity { | |
ProgressDialog mProgressDialog; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
findViewById(R.id.button).setOnClickListener(new OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
mProgressDialog = createProgressDialog("ぐるぐる"); | |
mProgressDialog.show(); | |
new Thread(new Runnable() { | |
@Override | |
public void run() { | |
try { | |
Thread.sleep(1000); | |
} catch (InterruptedException e) { | |
} | |
runOnUiThread(new Runnable() { | |
@Override | |
public void run() { | |
mProgressDialog.dismiss(); | |
} | |
}); | |
} | |
}).start(); | |
} | |
}); | |
} | |
private ProgressDialog createProgressDialog(String message) { | |
ProgressDialog progressDialog = new ProgressDialog(this); | |
progressDialog.setMessage(message); | |
return progressDialog; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment