title: How to Call FrameLayout slider in Different Activities in Android
body: <p>I have 3 activity say <code>first_activity</code>,<code>second_activity</code>,<code>third_activity</code>.I have used FrameLayout to open a slider .!</p>
  
  <p>Now what I want to open the slider on click of button that is available on all three activities.</p>
  
  <p>So now like in the Test 1 there is a button on the left side in the same way i have on all three activities so on click of that i want to open the slider.</p>
  
  <p>This my slider code</p>
  
  <pre><code>public class MainActivity extends Activity {
  
      // Within which the entire activity is enclosed
      private DrawerLayout mDrawerLayout;
  
      // ListView represents Navigation Drawer
      private ListView mDrawerList;
  
      // ActionBarDrawerToggle indicates the presence of Navigation Drawer in the
      // action bar
      private ActionBarDrawerToggle mDrawerToggle;
  
      // Title of the action bar
      private String mTitle = "";
  
      @SuppressLint("NewApi")
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          mTitle = "Test App";
          getActionBar().setTitle(mTitle);
  
          // Getting reference to the DrawerLayout
          mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
          mDrawerList = (ListView) findViewById(R.id.drawer_list);
  
          // Getting reference to the ActionBarDrawerToggle
          mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
                  R.drawable.ic_drawer, R.string.drawer_open,
                  R.string.drawer_close) {
  
              /** Called when drawer is closed */
              public void onDrawerClosed(View view) {
                  getActionBar().setTitle(mTitle);
                  invalidateOptionsMenu();
              }
  
              /** Called when a drawer is opened */
              public void onDrawerOpened(View drawerView) {
                  // getActionBar().setTitle("Approval Status");
                  invalidateOptionsMenu();
              }
          };
  
          // Setting DrawerToggle on DrawerLayout
          mDrawerLayout.setDrawerListener(mDrawerToggle);
  
          // Creating an ArrayAdapter to add items to the listview mDrawerList
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(
                  getBaseContext(), R.layout.drawer_list_item, getResources()
                          .getStringArray(R.array.menus));
  
          // Setting the adapter on mDrawerList
          mDrawerList.setAdapter(adapter);
  
          // Enabling Home button
          getActionBar().setHomeButtonEnabled(true);
  
          // Enabling Up navigation
          getActionBar().setDisplayHomeAsUpEnabled(true);
  
          // Setting item click listener for the listview mDrawerList
          mDrawerList.setOnItemClickListener(new OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                      int position, long id) {
                  // Getting an array of rivers
                  String[] menuItems = getResources().getStringArray(
                          R.array.menus);
  
                  // Currently selected river
                  mTitle = menuItems[position];
  
                  // Creating a fragment object
                  // WebViewFragment rFragment = new WebViewFragment();
                  //
                  // // Passing selected item information to fragment
                  // Bundle data = new Bundle();
                  // data.putInt("position", position);
                  // data.putString("url", getUrl(position));
                  // rFragment.setArguments(data);
                  //
                  //
                  // // Getting reference to the FragmentManager
                  // FragmentManager fragmentManager = getFragmentManager();
                  //
                  // // Creating a fragment transaction
                  // FragmentTransaction ft = fragmentManager.beginTransaction();
                  //
                  // // Adding a fragment to the fragment transaction
                  // ft.replace(R.id.content_frame, rFragment);
                  //
                  // // Committing the transaction
                  // ft.commit();
  
                  // Closing the drawer
                  mDrawerLayout.closeDrawer(mDrawerList);
  
              }
          });
      }
  
      protected String getUrl(int position) {
          switch (position) {
          case 0:
              return "";
          case 1:
              return "";
          case 2:
              return "";
          case 3:
              return "";
          case 4:
              return "";
          case 5:
              return "";
          case 6:
              return "";
          default:
              return "";
          }
      }
  
      @Override
      protected void onPostCreate(Bundle savedInstanceState) {
          super.onPostCreate(savedInstanceState);
          mDrawerToggle.syncState();
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          if (mDrawerToggle.onOptionsItemSelected(item)) {
              return true;
          }
          return super.onOptionsItemSelected(item);
      }
  
      /** Called whenever we call invalidateOptionsMenu() */
      @Override
      public boolean onPrepareOptionsMenu(Menu menu) {
          // If the drawer is open, hide action items related to the content view
          boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
  
          menu.findItem(R.id.action_settings).setVisible(!drawerOpen);
          return super.onPrepareOptionsMenu(menu);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  }
  </code></pre>