在Android应用上构建错误

时间:2015-01-01 23:11:07

标签: java android

我正在尝试创建一个Android应用程序但每次尝试构建应用程序时都会收到错误。

错误代码:

:app:compileDebugJava                 
C:\app\MainFragment.java:108: error: cannot find symbol
 renderView();webView.getSettings().setUserAgentString("my-app");

我的代码:所有代码:(http://pastebin.com/iEw21Sv6

renderView();

webView.getSettings().setUserAgentString("my-app");


// pull to refresh
SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) mRootView.findViewById(R.id.container_swipe_refresh);
swipeRefreshLayout.setColorSchemeResources(R.color.global_bg_front_inverse, R.color.global_bg_front, R.color.global_bg_front_inverse, R.color.global_bg_front);
swipeRefreshLayout.setOnRefreshListener(this);

// load and show data
if(mViewState==null || mViewState==ViewState.OFFLINE)
{
    loadData();
}
else if(mViewState==ViewState.CONTENT)

1 个答案:

答案 0 :(得分:1)

您的webView变量超出了范围。在您的代码中,请执行以下操作:

super.onActivityCreated(savedInstanceState);

            // restore webview state
            WebView webView = (WebView) mRootView.findViewById(R.id.fragment_main_webview);
            if(savedInstanceState!=null)
            {

                    webView.restoreState(savedInstanceState);
            }

            // setup webview
            renderView();

            webView.getSettings().setUserAgentString("my-app");