1
我正在嘗試開發這種「類似雲的」Android應用程序,但我無法在應用程序內部執行JavaScript。這裏是我的活動的Java部分...JavaScript不能在WebView中工作
這一切工作正常,但在http://www.webprogramming360.com/SpanishQuizMe/lesson.php它要求JavaScript頁面(它是活的,所以你可以看到它現在),但與onClick JavaScirpt事件上的功能這裏所謂的JavaScript頁面http://www.webprogramming360.com/SpanishQuizMe/lesson.js將不會執行。
我該如何獲得該功能執行? JavaScript甚至工作? 並會在Android Market將接受這樣的一個應用程序(一個是在雲/代碼的主要部分是在線直播)
package com.something.something;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
public class QuizSplashActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.splash);
// Let's display the progress in the activity title bar, like the
// browser app does.
getWindow().requestFeature(Window.FEATURE_PROGRESS);
WebView webview = new WebView(this);
setContentView(webview);
webview.getSettings().setJavaScriptEnabled(true);
final Activity activity = this;
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Activities and WebViews measure progress with different scales.
// The progress meter will automatically disappear when we reach 100%
activity.setProgress(progress * 1000);
}
});
webview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
//Users will be notified in case there's an error (i.e. no internet connection)
Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
});
//This will load the webpage that we want to see
webview.loadUrl("http://www.webprogramming360.com/SpanishQuizMe/");
}
}
您是否修復了此問題?我在Gingerbread手機上試過這個代碼,它似乎工作正常。 –