title: Stopping a fragment resetting itself
body: <p>I'm making a web browser. I've used fragments for tabbing but when the user goes from one tab to another and back again the webview's url resets and the user's url is lost.
  My question is; how do I stop the webview resetting when fragment switching.
  I've researched left right and center trying to solve this but haven't had any luck.
  Thank you!</p>
  
  <pre><code>public class HomeFragment extends Fragment {
  
  public HomeFragment(){}
  
  private WebView WebViewB1;
  private ProgressBar Pbar1;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
  
      View rootView = inflater.inflate(R.layout.fragment_home, container, false);
  
      Pbar1 = (ProgressBar) rootView.findViewById(R.id.progBar1);
      WebViewB1 = (WebView) rootView.findViewById(R.id.wvBrowserTab1);
  
      WebSettings webSettings = WebViewB1.getSettings();
      webSettings.setJavaScriptEnabled(true);
      WebViewB1.getSettings().setLoadWithOverviewMode(true);
      WebViewB1.getSettings().setUseWideViewPort(true);
      WebViewB1.getSettings().setBuiltInZoomControls(true);
      WebViewB1.getSettings().setAllowFileAccess(true);
  
      WebViewB1.setWebViewClient(new InsideWebViewClient());
      WebViewB1.setWebChromeClient(new WebChromeClient() {
          public void onProgressChanged(WebView view, int progress) 
          {
          if(progress &lt; 100 &amp;&amp; Pbar1.getVisibility() == ProgressBar.GONE){
              Pbar1.setVisibility(ProgressBar.VISIBLE);
          }
          Pbar1.setProgress(progress);
          if(progress == 100) {
              Pbar1.setVisibility(ProgressBar.GONE);
          }
       }
   });
  
          WebViewB1.loadUrl("http://google.com");
  
      return rootView;
  }
  
  }
  </code></pre>
  
  <p>Sliding menu activity below</p>
  
  <pre><code>public class MainActivity extends Activity {
  
  private DrawerLayout mDrawerLayout;
  private ListView mDrawerList;
  private ActionBarDrawerToggle mDrawerToggle;
  
  
  private CharSequence mDrawerTitle;
  
  private CharSequence mTitle;
  
  private String[] navMenuTitles;
  private TypedArray navMenuIcons;
  
  private ArrayList&lt;NavDrawerItem&gt; navDrawerItems;
  private NavDrawerListAdapter adapter;
  
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      mTitle = mDrawerTitle = getTitle();
  
      navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
  
      navMenuIcons = getResources()
              .obtainTypedArray(R.array.nav_drawer_icons);
  
      mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
      mDrawerList = (ListView) findViewById(R.id.list_slidermenu);
  
      navDrawerItems = new ArrayList&lt;NavDrawerItem&gt;();
  
      navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1)));
  
      navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1)));
  
      navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1)));
  
      navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1)));
  
      navDrawerItems.add(new NavDrawerItem(navMenuTitles[4], navMenuIcons.getResourceId(4, -1)));
  
      navDrawerItems.add(new NavDrawerItem(navMenuTitles[5], navMenuIcons.getResourceId(5, -1)));
  
      navMenuIcons.recycle();
  
      mDrawerList.setOnItemClickListener(new SlideMenuClickListener());
  
      adapter = new NavDrawerListAdapter(getApplicationContext(),
              navDrawerItems);
      mDrawerList.setAdapter(adapter);
  
      getActionBar().setDisplayHomeAsUpEnabled(true);
      getActionBar().setHomeButtonEnabled(true);
  
      mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
              R.drawable.ic_drawer,
              R.string.app_name,
              R.string.app_name
      ) {
          public void onDrawerClosed(View view) {
              getActionBar().setTitle(mTitle);
              invalidateOptionsMenu();
          }
  
          public void onDrawerOpened(View drawerView) {
              getActionBar().setTitle(mDrawerTitle);
              invalidateOptionsMenu();
          }
      };
      mDrawerLayout.setDrawerListener(mDrawerToggle);
  
      if (savedInstanceState == null) {
          displayView(0);
      }
  }
  private class SlideMenuClickListener implements
          ListView.OnItemClickListener {
      @Override
      public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position,
              long id) {
          displayView(position);
      }
  }
  public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.main, menu);
  
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      if (mDrawerToggle.onOptionsItemSelected(item)) {
          return true;
      }
      switch (item.getItemId()) {
      case R.id.action_settings:
          return true;
      default:
          return super.onOptionsItemSelected(item);
      }
  }
  
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
      boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
      menu.findItem(R.id.action_settings).setVisible(!drawerOpen);
      return super.onPrepareOptionsMenu(menu);
  }
  
  private void displayView(int position) {
      Fragment fragment = null;
  
      switch (position) {
      case 0:
          fragment = new HomeFragment();
          break;
      case 1:
          fragment = new Tab2();
          break;
      case 2:
          fragment = new Tab3();
          break;
      case 3:
          fragment = new Tab4();
          break;
      case 4:
          fragment = new Tab5();
          break;
      case 5:
          fragment = new Tab6();
          break;
  
      default:
          break;
      }
  
      if (fragment != null) {
          FragmentManager fragmentManager = getFragmentManager();
          fragmentManager.beginTransaction()
                  .replace(R.id.frame_container, fragment).commit();
  
          mDrawerList.setItemChecked(position, true);
          mDrawerList.setSelection(position);
          setTitle(navMenuTitles[position]);
          mDrawerLayout.closeDrawer(mDrawerList);
      } else {
          Log.e("MainActivity", "Error in creating fragment");
      }
  }
  
  @Override
  public void setTitle(CharSequence title) {
      mTitle = title;
      getActionBar().setTitle(mTitle);
  }
  
  @Override
  protected void onPostCreate(Bundle savedInstanceState) {
      super.onPostCreate(savedInstanceState);
      mDrawerToggle.syncState();
  }
  
  @Override
  public void onConfigurationChanged(Configuration newConfig) {
      super.onConfigurationChanged(newConfig);
      mDrawerToggle.onConfigurationChanged(newConfig);
  }
   }
  </code></pre>