Android Sherlock Fragment webview问题

时间:2013-03-08 11:59:14

标签: android android-layout android-intent android-webview

基于此参考http://wptrafficanalyzer.in/blog/implement-swiping-between-tabs-with-viewpager-in-action-bar-using-sherlock-library/

我正在使用sherlock片段的标签,即在一个标签中,当我尝试使用webview时,链接没有显示。它一直滚动而不显示内容。

公共类AppleFragment扩展了SherlockFragment {
    WebView w;

@SuppressLint("SetJavaScriptEnabled")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){

View v = inflater.inflate(R.layout.web, container, false);
     w=(WebView)v.findViewById(R.id.webView1);
     w.loadUrl("http://www.google.com");
     w.getSettings().setAppCacheMaxSize(1024*1024*8);
      w.getSettings().setAllowFileAccess(true);
      w.getSettings().setAppCacheEnabled(true);
      w.getSettings().setJavaScriptEnabled(true);
          return super.onCreateView(inflater, container, savedInstanceState);

}       
@Override
public void onStart() {     
    super.onStart();
}   

}

1 个答案:

答案 0 :(得分:1)

添加此代码并获取结果

w.setWebViewClient(new HelloWebViewClient());

public class HelloWebViewClient extends WebViewClient {

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }

}