Skip to content

Instantly share code, notes, and snippets.

@kojiokb
Created August 22, 2012 11:55
Show Gist options
  • Save kojiokb/3424835 to your computer and use it in GitHub Desktop.
Save kojiokb/3424835 to your computer and use it in GitHub Desktop.
2.2のぐるぐるしない対策
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