activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="아래쪽의핸들을드래그하세요." />
<SlidingDrawer
android:id="@+id/drawer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:content="@+id/content"
android:handle="@+id/handle"
android:topOffset="60dip" >
<ImageView
android:id="@id/handle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/andexam" />
<LinearLayout
android:id="@id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#808080"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="여기는서랍의안쪽입니다."
android:textColor="#000000" />
<Button
android:id="@+id/closedrawer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="서랍닫기" />
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
MainActivity.java
package com.example.slidingdrawerex01;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.SlidingDrawer;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.closedrawer).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
SlidingDrawer slidingDrawer = (SlidingDrawer)findViewById(R.id.drawer);
slidingDrawer.animateClose();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
'Android' 카테고리의 다른 글
대화상자 - Dialog (0) | 2013.04.02 |
---|---|
기타위젯 - WebView (0) | 2013.04.02 |
기타위젯 - AutoCompleteTextView (0) | 2013.04.02 |
날짜와 시간 - Chronometer (0) | 2013.04.02 |
날짜와 시간 - DatePickerDialog,TimePickerDialog (0) | 2013.04.02 |