sample code:

SlidingDrawerActivity

package com.android.slidingdraweractivity;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.SlidingDrawer;

public class SlidingDrawerActivity extends Activity {

    private static final String TAG = "SlideShow";

	private SlidingDrawer mDialerDrawer;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mDialerDrawer = (SlidingDrawer) findViewById(R.id.slidingdrawer);

        mDialerDrawer.setOnDrawerScrollListener(
        		new SlidingDrawer.OnDrawerScrollListener(){
        			public void onScrollStarted() {
        				Log.d (TAG, "This is onScrollStarted.");
        			}
        			public void onScrollEnded() {
        				Log.d (TAG, "This is onScrollEnded.");

        			}
        			}
        		);

        mDialerDrawer.setOnDrawerOpenListener(
        		new SlidingDrawer.OnDrawerOpenListener() {
        			public void onDrawerOpened() { }

        		});

        mDialerDrawer.setOnDrawerCloseListener(
        		new SlidingDrawer.OnDrawerCloseListener() {
        			public void onDrawerClosed() { }
        		});
    }
}

layout\main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#808080"
    >

<SlidingDrawer
    android:id="@+id/slidingdrawer"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:handle="@+id/handle"
    android:content="@+id/content" >

    <LinearLayout
        android:id="@id/handle"
        android:layout_width="88dip"
        android:layout_height="44dip"
        android:background="#0000FF"/>

    <LinearLayout
        android:id="@id/content"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#00FF00">

        <Button
            android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button"/>

        <EditText
            android:id="@+id/editText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>

    </LinearLayout>

</SlidingDrawer>

<!--
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"
    />
-->

</LinearLayout>

By admin-powenko

Dr. Powen Ko is a teacher and CEO on LoopTek LLC, and like to teaching. if you need to class, please let PowenKo know, he will love to service and sharing. LoopTek web site is www.looptek.com

Leave a Reply