いくつかの html5 アニメーションを再生するために を使用していますが、アニメーションはいくつかのコードWebView
に依存しています。Web ページが読み込まれる前にコードjavascript
を挿入する必要があります。javascript
WebView
class AnimWebView extends WebView{
getSettings().setJavaScriptEnabled(true);
loadAnimation(String animUrl){
//get javascript code
String js_code = getMyJsCode();
//inject the javascript code to WebView
mWebView.loadUrl("javascript:" + js_code);
//load animation
mWebView.loadUrl(animUrl);
}
}
AnimWebView animContainer = new AnimWebView(context);
// load first animation, the animation works fine.
animContainer.loadAnimation("file:///android_asset/animations/test1/index.html");
//after one minute load second animation(I omit the delay code.)
//it doesn't work because JS code can't be find.
animContainer.loadAnimation("file:///android_asset/animations/test2/index.html");
最初の 2 番目は機能し、2 回目は失敗したため、最初の 1 回目以降はコードとキャッシュをクリアする必要があると思います。
だから私は、、しようとしclearView()
ましstopLoading()
たloadUrl("about:blank")
。しかし、それらはすべて機能しません。
何か提案はありますか?