gpt4 book ai didi

java - 进度条加载后的新 Activity - Android -

转载 作者:行者123 更新时间:2023-12-02 07:48:39 24 4
gpt4 key购买 nike

加载进度条后无法启动新 Activity 。我卡在进度条上,不知道应该将新 Activity 放在哪里。有什么办法可以解决我的问题吗?

ProgressBar myProgressBar;
int myProgress = 0;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);

myProgressBar=(ProgressBar)findViewById(R.id.progressbar_Horizontal);

new Thread(myThread).start();
}

private Runnable myThread = new Runnable(){

public void run() {
// TODO Auto-generated method stub
while (myProgress<100){
try{
myHandle.sendMessage(myHandle.obtainMessage());
Thread.sleep(50);
}
catch(Throwable t){

}
}
}
Handler myHandle = new Handler(){

@Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
myProgress++;
myProgressBar.setProgress(myProgress);
}
};
};

}

最佳答案

请将其添加到您的按钮点击事件中。

            progressDialog = ProgressDialog.show(this, "", "Loading...");
new Thread() {

public void run() {

Intent ddIntent = new Intent(
MainActivity.this, MainWall.class);
startActivity(ddIntent);
progressDialog.dismiss();
}

}.start();

关于java - 进度条加载后的新 Activity - Android -,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10506791/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com