我正在开发一个 Android 应用程序。有一个Activity
显示Button
。
当一个按钮被按下时,ProgressDialog
应该出现并且后面ProgressDialog
应该有另一个应该打开的 Activity。
我想要其他活动,而不是按钮所在的 Activity。我怎样才能做到这一点?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.gamemenu);
TextView tvStart = (TextView)findViewById(R.id.start);
//TextView tvSettings = (TextView)findViewById(R.id.settings);
TextView tvAbout = (TextView)findViewById(R.id.instruction);
TextView tvExit = (TextView)findViewById(R.id.exit);
tvStart.setOnClickListener(this);
//tvSettings.setOnClickListener(this);
tvAbout.setOnClickListener(this);
tvExit.setOnClickListener(this);
}
public void onClick(View v) {
switch(v.getId()){
case R.id.start:
ProgressDialog pd=new ProgressDialog(StartMenu.this);
pd=ProgressDialog.show(StartMenu.this,"Loading","Please Wait",false);
Handler handler=new Handler();
Runnable gotologin=new Runnable()
{
public void run()
{
startActivity(new Intent(StartMenu.this,AndroidGame.class));
finish();
}
};
handler.postDelayed(gotologin, 3000);
pd.dismiss();
// finish();
break;
// Intent iStart = new Intent(getApplicationContext(), AndroidGame.class );
// startActivity(iStart);
// break;
/*case R.id.settings:
Intent iSettings = new Intent(getApplicationContext(), GameSettings.class );
startActivity(iSettings);
break;*/
case R.id.instruction:
Intent inInstructions = new Intent(getApplicationContext(), Instructions.class );
startActivity(inInstructions);
break;
case R.id.exit:
((Activity)v.getContext()).finish();
//this.finish();
break;
}
}