-4

I like to open sliding drawer from any out side button not with its child button handle , If any one have any answer or tutorial please help me?

I want to open a slider from any other button in layout not from handle button ... not from its child button ??

like if I have any button in xml.. and when I click on it slider open .

Android Sliding Up View please check it and see the screen shot I don't have that much reputation so that I upload Image

I want to click on show button the slider opens not on slider

Community
  • 1
  • 1

2 Answers2

0

The "Navigation Drawer" can be opened programmatically with mDrawerLayout.openDrawer(mDrawerContentLayout). Here's some info how to set it up:

private DrawerLayout mDrawerLayout;
private RelativeLayout mDrawerContentLayout;

Get the reference to drawerView in your Activity onCreate():

mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerContentLayout = (RelativeLayout) findViewById(R.id.drawer_content);

Call this on your button click when you want drawer opened:

mDrawerLayout.openDrawer(mDrawerContentLayout);

I used a RelativeLayout as content view of my drawer, but you can use any which suits you. Just remember, the mDrawerLayout layout should be inside mDrawerLayout (which is actually a android.support.v4.widget.DrawerLayout) and should have the android:layout_gravity="start" attribute.

Here's the (abbreviated) activity layout that I used:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/drawer_layout"
  android:layout_width="match_parent"
  android:layout_height="match_parent" >

  <android.support.v4.view.ViewPager
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <android.support.v4.view.PagerTitleStrip
      android:id="@+id/pager_title_strip"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_gravity="top"
      android:background="#33b5e5"
      android:paddingBottom="4dp"
      android:paddingTop="4dp"
      android:textColor="#fff" />
  </android.support.v4.view.ViewPager>


  <RelativeLayout
    android:id="@+id/drawer_content"
    android:layout_width="@dimen/nav_drawer_width"
    android:layout_height="match_parent"
    android:layout_gravity="start" >

    <ListView
      ... />

</android.support.v4.widget.DrawerLayout>

You can find more details in the API documentation, the developer docs and the design patterns.

Saran
  • 3,845
  • 3
  • 37
  • 59
0

Okay, if you want to open slider on it's button's click then use below code.

sliding_menu = (Button) findViewById(R.id.slidingMenu);
        sliding_menu.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                menu.showMenu();
            }
        });
InnocentKiller
  • 5,234
  • 7
  • 36
  • 84