title: Getting an error in Bitz and pizza app that i am using to build it with Head first android development book
body: <p>When i am adding viewpager using fragment pager adapter....it show error ,all the code looks fine but in mainactivity.java its an error.</p>
  <p>I think mainly the problem is in the import function, which is used in older version ....but i can't find anything in any of the browsers(google and youtube etc.</p>
  <p>My code of main activity is this:-</p>
  <pre><code> package com.hfad.bitzandpizza;
  
   import androidx.appcompat.app.AppCompatActivity;
  
   import androidx.fragment.app.FragmentManager;
  
   import android.content.Intent;
  
   import android.os.Bundle;
  
   import android.view.Menu;
  
   import android.view.MenuItem;
  
   import androidx.appcompat.widget.ShareActionProvider;
  
    import androidx.appcompat.widget.Toolbar;
  
    import androidx.core.view.MenuItemCompat;
  
   import androidx.fragment.app.Fragment;
  
   import androidx.fragment.app.FragmentPagerAdapter;
  
   import androidx.viewpager.widget.ViewPager;
  
   public class MainActivity extends AppCompatActivity {
  
  private ShareActionProvider shareActionProvider;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
      SectionspagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
      ViewPager pager = (ViewPager) findViewById(R.id.pager);
      pager.setAdapter(pagerAdapter);
  }
  
      @Override
  public boolean onCreateOptionsMenu(Menu menu){
      getMenuInflater().inflate(R.menu.menu_main, menu);
      MenuItem menuItem = menu.findItem(R.id.action_share);
      shareActionProvider = (ShareActionProvider) 
      MenuItemCompat.getActionProvider(menuItem);
      setShareActionIntent(&quot;Want to join me for pizza?&quot;);
      return super.onCreateOptionsMenu(menu);
    }
  
  
     private void setShareActionIntent(String text){
      Intent intent = new Intent((Intent.ACTION_SEND));
      intent.setType(&quot;text/plain&quot;);
      intent.putExtra(Intent.EXTRA_TEXT ,text);
      shareActionProvider.setShareIntent(intent);
    }
  
    @Override
  public boolean onOptionsItemSelected(MenuItem item){
      switch (item.getItemId()){
          case R.id.action_create_order:
              Intent intent = new Intent(this , OrderActivity.class);
              startActivity(intent);
              return true;
          default:
              return super.onOptionsItemSelected(item);
      }
   }
  
  
      private class SectionsPagerAdapter extends FragmentPagerAdapter{
      public SectionsPagerAdapter(FragmentManager fm){
          super(fm);
      }
  
      @Override
  public int getCount(){
          return 4;
      }
  
      @Override
  public Fragment getItem(int position){
          switch (position){
              case 0 :
                  return  new TopFragment();
              case 1:
                  return new PizzaFragment();
              case 2:
                  return new PastaFragment();
              case 3:
                  return new StoresFragment();
          }
          return null;
      }
    }
  
   }
  </code></pre>
  <p>please check this....to find an error it ruins my 2 days .....</p>
  <p>Thankyou very much</p>
  <p><a href="https://i.stack.imgur.com/Zp1CA.png" rel="nofollow noreferrer">first error is descripted pager adapter</a></p>
  <p><a href="https://i.stack.imgur.com/9lwZS.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p><a href="https://i.stack.imgur.com/vJ56i.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>these are all the error I have encountered......</p>