Created
October 21, 2015 16:05
-
-
Save Momijinn/7c30813ec73b748511e7 to your computer and use it in GitHub Desktop.
AndroidでProgressDialog
This file contains hidden or 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 ProgressDialog_sample extends AppCompatActivity implements Runnable{ | |
//ProgressDialogを定義 | |
private ProgressDialog mProgressDialog; | |
private Thread thread; | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
//ProgressDialogの設定 | |
mProgressDialog = new ProgressDialog(this); | |
mProgressDialog.setTitle("Bluetooth有効化"); | |
mProgressDialog.setMessage("Loading now..."); | |
mProgressDialog.setCancelable(false); | |
mProgressDialog.setProgress(ProgressDialog.STYLE_SPINNER); | |
mProgressDialog.show(); | |
thread = new Thread(this); | |
thread.start(); //ProgresDialogの開始 | |
} | |
@Override | |
public void run() { | |
//プログレスダイアログからの実行 | |
//とりあえず2秒待つ | |
try { | |
Thread.sleep(2000); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
mProgressDialog.dismiss(); //ProgresDialogの停止 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment