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手机上试过这个代码,它似乎工作正常。 –