webviewで読み込まれたウェブサイトを持っているアンドロイドアプリを作成しました。私は5秒間ロードするスプラッシュ画面を作成し、その間に進行状況バーを配置して、ウェブサイトの読み込み時間を調整しました。webviewが読み込まれるまでスプラッシュ画面を読み込むには
これで、ページが読み込まれ、進行状況バーのページが削除されるまでスプラッシュ画面を表示する必要がありました。私は次のコードで作業しています。
public class Splashscreen extends Activity {
// Set Duration of the Splash Screen
long Delay = 5000;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Remove the Title Bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
// Get the view from splash_activity.xml
setContentView(R.layout.splash);
// Create a Timer
Timer RunSplash = new Timer();
// Task to do when the timer ends
TimerTask ShowSplash = new TimerTask() {
@Override
public void run() {
// Close SplashScreenActivity.class
finish();
// Start MainActivity.class
Intent myIntent = new Intent(Splashscreen.this,
MainActivity.class);
startActivity(myIntent);
}
};
// Start the timer
RunSplash.schedule(ShowSplash, Delay);
}
}
どこで変更しますか?
あなた 'WebView'どこにあるの? – JohnnyAW
メインアクティビティは –
です。主なアクティビティを開始した後にのみ、 'WebView'がURLを読み込むようになりますか? – JohnnyAW