package com.example.progressdialog;
import com.example.progressdialog.R;
import android.os.Bundle;
import android.app.Activity;
import android.app.ProgressDialog;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
private ProgressDialog progress;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
progress = new ProgressDialog(this);
}
public void open(View view){
progress.setMessage("Doing Progressive Things");
progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progress.setIndeterminate(false);
progress.show();
final int totalProgressTime = 100;
final Thread t = new Thread(){
@Override
public void run(){
int jumpTime = 0;
while(jumpTime < totalProgressTime){
try {
sleep(500);
jumpTime += 1;
progress.setProgress(jumpTime);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
t.start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
如何在程序中添加第二个按钮?我想添加第二个按钮,允许我在我的应用程序中打开另一个窗口。我无法弄清楚我想把第二个onclick监听器放在哪里。谁能帮助我?