抽屜close   抽屜OPEn  

 


 

 

public class MainActivity extends Activity {
private ListView gridView;
private SlidingDrawer slidingDrawer;
private ImageView imvg;
// GridView图标
private int[] icons = { R.drawable.ic_launcher, R.drawable.ic_launcher,
R.drawable.ic_launcher, R.drawable.ic_launcher,
R.drawable.ic_launcher ,R.drawable.ic_launcher, R.drawable.ic_launcher,
R.drawable.ic_launcher, R.drawable.ic_launcher,
R.drawable.ic_launcher };
// GridView文本
private String[] items = { "Alarm", "Camera", "Clock", "Music", "TV","Alarm", "Camera", "Clock", "Music", "TV"};

/** Called when the activity is first created. */
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gridView = (ListView) findViewById(R.id.gridView1);
slidingDrawer = (SlidingDrawer) findViewById(R.id.slidingDrawer1);
// imvg = (ImageView) this.findViewById(R.id.imageView1);

BaseAdapter adapter = new BaseAdapter() {

@Override
public int getCount() {
// TODO Auto-generated method stub
return items.length;
}

@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}

@Override
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return 0;
}

@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {

View v = MainActivity.this.getLayoutInflater().inflate(
R.layout.grid, null);
TextView tv = (TextView) v.findViewById(R.id.textView1);
tv.setText(items[arg0]);
ImageView imv = (ImageView) v.findViewById(R.id.imV1);
imv.setImageResource(icons[arg0]);
return v;
}

};
gridView.setAdapter(adapter);
// 抽屉打開
slidingDrawer.setOnDrawerOpenListener(new OnDrawerOpenListener() {
@Override
public void onDrawerOpened() {
// TODO Auto-generated method stub
//imvg.setImageResource(android.R.drawable.btn_star_big_on);
}
});
// 抽屉關閉
slidingDrawer.setOnDrawerCloseListener(new OnDrawerCloseListener() {
@Override
public void onDrawerClosed() {
// TODO Auto-generated method stub
//imvg.setImageResource(android.R.drawable.btn_star_big_off);
}
});

}

}

 


 

 

main:

 

 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

 

<SlidingDrawer
android:id="@+id/slidingDrawer1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:content="@+id/content"
android:handle="@+id/handle"
android:orientation="horizontal" >

 

<Button
android:id="@+id/handle"
android:layout_width="wrap_content"
android:layout_height="39dp"
android:background="@drawable/right" />

 

<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent" >

 

<ListView
android:id="@+id/gridView1"
android:layout_width="wrap_content"
android:layout_height="460dp" >

 

</ListView>

 

</LinearLayout>

</SlidingDrawer>

 

</RelativeLayout>

 

 

 


 

 

grid.xml

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"

android:orientation="vertical" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="@drawable/b"
android:orientation="horizontal" >

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />

<ImageView
android:id="@+id/imV1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>

</LinearLayout>

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 小Chiu 的頭像
    小Chiu

    Cuiu's Home

    小Chiu 發表在 痞客邦 留言(0) 人氣()