进度条对我不起作用。我试图展示一些正在进行的细节。但我不能,我做错了什么?请帮我。
活动文件名 - MainActivity.java
package com.example.sqliteexample;
import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.app.ProgressDialog;
import android.view.Menu;
public class MainActivity extends Activity {
private Handler handler = new Handler();
private ProgressDialog dialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//dialog = ProgressDialog.show(this,getString(R.string.loading) ,getString(R.string.alignMsg));
dialog = ProgressDialog.show(this,"Loading", "Loading the Image of the Day");
Thread th = new Thread()
{
public void run() {
handler.post(
new Runnable (){
@Override
public void run() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
dialog.dismiss();
}});
}};
th.start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}