假设你有两个activity 分别LoadingScreen activity (loadingscreen.xml layout), 和 Main activity (main.xml).
然后在LoadingScreen中
ProgressBar pb = (ProgressBar)findViewById(R.id.ProgressBar01);
/* Setting up handler for ProgressBar */
pbHandle = new Handler(){
@Override
public void handleMessage(Message msg) {
/* get the value from the Message */
int progress = msg.arg1;
pb.setProgress(progress);
}
};
然后在主activity中
/* Creating a message */
Message progressMsg = new Message();
progressMsg.arg1 = progress();
/* Sending the message */
pbHandle.sendMessage(progressMsg);