0

As we load Webview in fragment like this:

private WebView viewer = null;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        viewer = (WebView) inflater
                .inflate(R.layout.tut_view, container, false);
        return viewer;
    }

    public void updateUrl(String newUrl) {
        if (viewer != null) {
            viewer.loadUrl(newUrl);
        }
    }

But i wanted to use linear layout instead of webview. I try this but errors come out.

 private LinearLayout viewer ;
   @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
         viewer =  (LinearLayout) inflater.inflate(R.layout.tut_view, container, false);


        View fragment = inflater.inflate(R.layout.tut_view, null);
        return viewer;
    }
    public void updateUrl(String newUrl) {
        if (viewer != null) {


        }
    }
Amarjit
  • 4,327
  • 2
  • 34
  • 51

1 Answers1

1

You should have LinearLayout as root in your xml file. Also you do not need to cast the inflated view as return type is View. Please read the fragment spec.

k_shil
  • 2,108
  • 1
  • 20
  • 25
  • but each time i want to reload activity in fragment view just let me know what is the basic check in this code: if (viewer != null) { } – Arslan Ahmad Nov 30 '12 at 06:47