Can not resolve method 'findViewById(int)'

前端 未结 9 813
孤城傲影
孤城傲影 2021-02-05 03:08

I\'m having a trouble with findViewByid but I can\'t find where the problem is.

Here\'s my FirstFragment class code:

import and         


        
9条回答
  •  隐瞒了意图╮
    2021-02-05 03:28

    You need to do this in onCreateView:

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle   savedInstanceState) {
       View view =  inflater.inflate(R.layout.secondefragment, container, false);
        mWebView = (WebView) view.findViewById(R.id.activity_main_webview);
       progressBar = (ProgressBar) view.findViewById(R.id.progressBar1);
    
       WebSettings webSettings = mWebView.getSettings();
       webSettings.setJavaScriptEnabled(true);
       mWebView.loadUrl("http://www.google.com");
    
       return view;
    
    
    }
    

提交回复
热议问题