zoukankan      html  css  js  c++  java
  • 015、SlidingDrawer 隐藏式抽屉

    SlidingDrawer控件,实现抽屉效果。
    SlidingDrawer配置采用了水平展开或垂直展开两种(android:orientation)方式,在XML里必须指定其使用的android:handle与android:content,前者委托要展开的图片(Layout配置,即把手),后者为委托要展开的LayoutContent。
        <SlidingDrawer
            android:id="@+id/sd"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/tv"
            android:content="@+id/sd_content"
            android:handle="@+id/sd_handle"
            android:orientation="horizontal" >
            <ImageView
                android:id="@id/sd_handle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/open" />
            <GridView
                android:id="@id/sd_content"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:numColumns="2" >
            </GridView>
        </SlidingDrawer>

     

    在代码中,通过该控件的setOnDrawerOpenListener()与setOnDrawerCloseListener()方法监控抽屉的打开和关闭

            sd.setOnDrawerOpenListener(new OnDrawerOpenListener() {
                @Override
                public void onDrawerOpened() {
                    // TODO Auto-generated method stub
                    sd_handle.setImageResource(R.drawable.close);
                    tv.setText(getString(R.string.tv_close));
                }
            });
            sd.setOnDrawerCloseListener(new OnDrawerCloseListener() {
                @Override
                public void onDrawerClosed() {
                    // TODO Auto-generated method stub
                    sd_handle.setImageResource(R.drawable.open);
                    tv.setText(getString(R.string.tv_open));
                }
            });
  • 相关阅读:
    面向对象
    ArrayList 集合
    JAVA 方法
    JAVA数组
    JAVA基础2
    JAVA基础1(语法)
    JAVA基础(jdk安装和环境变量的配置)
    数据结构练习题
    多表查询
    数据约束
  • 原文地址:https://www.cnblogs.com/zyh-blog/p/3343632.html
Copyright © 2011-2022 走看看