SlidingDrawerActivity(抽屉)
package com.SlidingDrawerActivity;
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.SlidingDrawer;
import android.widget.TextView;
public class SlidingDrawerActivity extends Activity implements OnClickListener {
private SlidingDrawer mDialerDrawer;
private Button button ;
private EditText text;
private TextView tv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv=(TextView)findViewById(R.id.tv);
button=(Button)findViewById(R.id.button);
button.setOnClickListener(this);
text =(EditText)findViewById(R.id.editText);
mDialerDrawer = (SlidingDrawer) findViewById(R.id.slidingdrawer);
mDialerDrawer.setOnDrawerScrollListener(new SlidingDrawer.OnDrawerScrollListener() {
@Override
public void onScrollStarted() {
Log.v("SlidingDrawerActivity", "onScrollStarted()");
}
@Override
public void onScrollEnded() {
Log.v("SlidingDrawerActivity", "onScrollEnded()");
}
});
mDialerDrawer.setOnDrawerOpenListener(new SlidingDrawer.OnDrawerOpenListener() {
@Override
public void onDrawerOpened() {
Log.v("SlidingDrawerActivity", "onDrawerOpened()");
}
});
mDialerDrawer.setOnDrawerCloseListener(new SlidingDrawer.OnDrawerCloseListener() {
@Override
public void onDrawerClosed() {
Log.v("SlidingDrawerActivity", "onDrawerClosed()");
}
});
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String str=String.valueOf(text.getText());
tv.setText(str);
}
}
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.SlidingDrawer;
import android.widget.TextView;
public class SlidingDrawerActivity extends Activity implements OnClickListener {
private SlidingDrawer mDialerDrawer;
private Button button ;
private EditText text;
private TextView tv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv=(TextView)findViewById(R.id.tv);
button=(Button)findViewById(R.id.button);
button.setOnClickListener(this);
text =(EditText)findViewById(R.id.editText);
mDialerDrawer = (SlidingDrawer) findViewById(R.id.slidingdrawer);
mDialerDrawer.setOnDrawerScrollListener(new SlidingDrawer.OnDrawerScrollListener() {
@Override
public void onScrollStarted() {
Log.v("SlidingDrawerActivity", "onScrollStarted()");
}
@Override
public void onScrollEnded() {
Log.v("SlidingDrawerActivity", "onScrollEnded()");
}
});
mDialerDrawer.setOnDrawerOpenListener(new SlidingDrawer.OnDrawerOpenListener() {
@Override
public void onDrawerOpened() {
Log.v("SlidingDrawerActivity", "onDrawerOpened()");
}
});
mDialerDrawer.setOnDrawerCloseListener(new SlidingDrawer.OnDrawerCloseListener() {
@Override
public void onDrawerClosed() {
Log.v("SlidingDrawerActivity", "onDrawerClosed()");
}
});
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String str=String.valueOf(text.getText());
tv.setText(str);
}
}
res\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">
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"/>
<TextView
android:id="@+id/tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<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">
<Button
android:id="@id/handle"
android:layout_width="88dip"
android:layout_height="44dip"
android:background="@drawable/handle"/>
<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>
</LinearLayout>
<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">
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"/>
<TextView
android:id="@+id/tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<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">
<Button
android:id="@id/handle"
android:layout_width="88dip"
android:layout_height="44dip"
android:background="@drawable/handle"/>
<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>
</LinearLayout>
res\drawable\handle.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false"
android:state_enabled="true"
android:drawable="@drawable/handle_normal" />
<item android:state_pressed="true"
android:drawable="@drawable/handle_pressed" />
<item android:state_focused="true"
android:state_enabled="true"
android:drawable="@drawable/handle_selected"/>
<item android:state_enabled="true"
android:drawable="@drawable/handle_normal" />
<item android:state_focused="true"
android:drawable="@drawable/handle_selected" />
</selector>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false"
android:state_enabled="true"
android:drawable="@drawable/handle_normal" />
<item android:state_pressed="true"
android:drawable="@drawable/handle_pressed" />
<item android:state_focused="true"
android:state_enabled="true"
android:drawable="@drawable/handle_selected"/>
<item android:state_enabled="true"
android:drawable="@drawable/handle_normal" />
<item android:state_focused="true"
android:drawable="@drawable/handle_selected" />
</selector>