0

我最近启动了一个测验应用程序,我找到了一个很好的网站,我可以在其中使用图像、多个响应进行测验,并在开始时显示分数。

我不知道我的错误在哪里,因为 ggoogle.com 有效,但我的测验没有。

这是我要加载的链接surveyanyplace.com/s/pozitiemers

我的课:

public class ChestionareA extends MainActivity2A {
    /** Called when the activity is first created. */

    WebView web;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.chestionare_a);

        web = (WebView) findViewById(R.id.webview01);
        web.setWebViewClient(new myWebClient());
        web.getSettings().setJavaScriptEnabled(true);
        web.loadUrl("http://surveyanyplace.com/s/pozitiemers/");
    }

    public class myWebClient extends WebViewClient
    {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            // TODO Auto-generated method stub
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            // TODO Auto-generated method stub

            view.loadUrl(url);
            return true;

        }
    }

    // To handle "Back" key press event for WebView to go back to previous screen.
   @Override
   public boolean onKeyDown(int keyCode, KeyEvent event)
  {
    if ((keyCode == KeyEvent.KEYCODE_BACK) && web.canGoBack()) {
        web.goBack();
        return true;
    }
    return super.onKeyDown(keyCode, event);
   }
}
4

1 回答 1

0

还添加了清单 android:hardwareAccelerated="true"。不确定它是否有帮助。

下面的代码对我有用。尝试这个。

public class MainActivity extends Activity {

WebView wv;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    wv= (WebView) findViewById(R.id.wv);
    wv.getSettings().setPluginsEnabled(true);
    WebSettings webSettings = wv.getSettings();
    webSettings.setJavaScriptEnabled(true);
    wv.getSettings().setDomStorageEnabled(true);

    wv.setWebViewClient(new MyOwnWebViewClient());
    wv.loadUrl("http://surveyanyplace.com/s/pozitiemers/");
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}
class MyOwnWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl("http://surveyanyplace.com/s/pozitiemers/");
        return true;
    }
 }

activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<WebView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/wv"></WebView>
</LinearLayout>

结果快照

在此处输入图像描述

于 2013-03-25T06:51:26.933 回答