user666
user666

Reputation: 492

Android Navigation Drawer without Listview

i want to create a swipe menu like navigation drawer. But there is going to be textviews and imageviews, like a half activity. Is it possible to make this?

Upvotes: 6

Views: 5039

Answers (3)

tasomaniac
tasomaniac

Reputation: 10342

You can use NavigationDrawer from support library.

Include a FrameLayout as a child of the DrawerLayout and make the android:layout_gravity="left". Then put anything you want in it. You do not have to use only ListView. What you put in a view that has left gravity will be the left menu

Upvotes: 12

ARLabs
ARLabs

Reputation: 1524

I did it in this way: Created a ListView with only one child (row) with a Layout of what I want inside it.

Here the code:

        // Add Header
    ListAdapter adapter = new BaseAdapter() {

        Object mObj = new Object(); // Unusefull

        @Override
        public int getCount() { return 1; }

        @Override
        public Object getItem(int position) { return mObj; }

        @Override
        public long getItemId(int position) { return position; }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if( convertView == null )
            {
                convertView = getLayoutInflater().inflate( R.layout.drawer_layout, null );
            }
            return convertView;
        }
    };

    mDrawerList = (ListView) findViewById(R.id.drawer);
    if (mDrawerList != null)
        mDrawerList.setAdapter(adapter);

Upvotes: 1

henry4343
henry4343

Reputation: 3921

Yes it's possible. This is tutorial for navigation drawer

and you can create custom fragment instead of listview. use fragment to display slider menu

Upvotes: 1

Related Questions