title: Android Open WebView inside Fragment - crash
body: <p>App need to open some websites when i touch buttons. There are 2 tabs (2 fragments) with different buttons (1 button = 1 link)
  When i click a Button that need to open WebView (to open a link) application crash. I think, mistake is somewhere in AFragment.java</p>
  
  <p>main.java (it's good 99,9%)</p>
  
  <pre><code>import android.app.ActionBar;
  import android.app.ActionBar.Tab;
  import android.app.Activity;
  import android.app.Fragment;
  import android.app.FragmentTransaction;
  import android.content.Context;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MenuItem;
  import android.widget.Toast;
  
  public class MainActivity extends Activity {
      public static Context appContext;
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          appContext = getApplicationContext();
  
         //ActionBar
          ActionBar actionbar = getActionBar();
          actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  
          ActionBar.Tab PTab = actionbar.newTab().setText("One");
          ActionBar.Tab DTab = actionbar.newTab().setText("Two");
  
  
          Fragment OneFragment = new AFragment();
          Fragment TwpFragment = new BFragment();
  
          PTab.setTabListener(new MyTabsListener(OneFragment));
          DTab.setTabListener(new MyTabsListener(TwoFragment));
  
  
          actionbar.addTab(PTab);
          actionbar.addTab(DTab);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          MenuInflater inflater = getMenuInflater();
          inflater.inflate(R.menu.activity_main, menu);
          return true;
      }
  
  
      @Override
      protected void onSaveInstanceState(Bundle outState) {
          super.onSaveInstanceState(outState);
          outState.putInt("tab", getActionBar().getSelectedNavigationIndex());
      }
  
  }
  
  
  class MyTabsListener implements ActionBar.TabListener {
      public Fragment fragment;
  
      public MyTabsListener(Fragment fragment) {
          this.fragment = fragment;
      }
  
      @Override
      public void onTabReselected(Tab tab, FragmentTransaction ft) {
          //Toast.makeText(MainActivity.appContext, "Reselected!", Toast.LENGTH_LONG).show();
      }
  
      @Override
      public void onTabSelected(Tab tab, FragmentTransaction ft) {
          ft.replace(R.id.fragment_container, fragment);
      }
  
      @Override
      public void onTabUnselected(Tab tab, FragmentTransaction ft) {
          ft.remove(fragment);
      }
  
  }
  </code></pre>
  
  <p>AFragment.java:</p>
  
  <pre><code>    import android.app.Fragment;
      import android.content.Intent;
      import android.os.Bundle;
      import android.view.LayoutInflater;
      import android.view.View;
      import android.view.ViewGroup;
      import android.webkit.WebView;
      import android.widget.Button;
      import android.widget.EditText;
  
  
      public class AFragment extends Fragment {
  
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle  
                   SavedInstanceState) {                          
              // Inflate the layout for this fragment
              return inflater.inflate(R.layout.afragment, container, false);
          }
  
          // On Button Click
          public void openIt(View view) {
              Intent intent = new Intent(view.getContext(), openPage.class);
              startActivity(intent); 
                       }
              }
  </code></pre>
  
  <p>openPage.class:</p>
  
  <pre><code>    import android.webkit.WebView;
      import android.app.Activity;
      import android.os.Bundle;
  
      public class openPage extends Activity {
  
          WebView myWebView;
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
                      setContentView(R.layout.webview);
  
  
              WebView myWebView = (WebView) findViewById(R.id.webview);
              myWebView.loadUrl("http://safhkalfsd.com");
  
          }
      }
  </code></pre>
  
  <p>Layouts are fine 99,99%
  i put
          android:onClick="openIt"
  in afragment.xml inside Button 
  THANK YOU</p>