PowenKo > Android > Customer UI > Sliding Drawer

January 15, 2012   ·   0 Comments

device-2012-01-15-152041

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>

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Android7

Amazon

adsbygoogle

Recent Posts

Categories

Amazon