//SlidingDemo.java
package com.example.widgetdemo1;
import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.widget.SlidingDrawer; import android.widget.Toast;
public class SlidingDemo extends Activity { private SlidingDrawer drawer; private static final String TAG = "SlidingDemo";
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sliding1); drawer = (SlidingDrawer)findViewById(R.id.slidingdrawer); drawer.setOnDrawerCloseListener(new SlidingDrawer.OnDrawerCloseListener() { @Override public void onDrawerClosed() { Log.i(TAG, "DrawerClose"); Toast.makeText(SlidingDemo.this, "DrawerClose", Toast.LENGTH_SHORT).show(); } }); drawer.setOnDrawerOpenListener(new SlidingDrawer.OnDrawerOpenListener() { @Override public void onDrawerOpened() { Log.i(TAG, "DrawerOpen"); Toast.makeText(SlidingDemo.this, "DrawerOpen", Toast.LENGTH_SHORT).show(); } }); drawer.setOnDrawerScrollListener(new SlidingDrawer.OnDrawerScrollListener() { @Override public void onScrollStarted() { Log.i(TAG, "onScrollStarted"); Toast.makeText(SlidingDemo.this, "onScrollStarted", Toast.LENGTH_SHORT).show(); } @Override public void onScrollEnded() { Log.i(TAG, "onScrollEnded"); Toast.makeText(SlidingDemo.this, "onScrollEnded", Toast.LENGTH_SHORT).show(); } }); } }
|