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));
                }
            });
  • 相关阅读:
    递归 例子 c
    Static和extern关键字 c
    typedef的作用
    预编译指令包括:宏定义;条件编译;文件包含(就是include)
    枚举 c
    结构体 可以由多个不同类型的数据构成
    变量类型 c
    指针类型:非常重要 c
    设计模式学习--原型模式
    设计模式学习--工厂方法模式
  • 原文地址:https://www.cnblogs.com/zyh-blog/p/3343632.html
Copyright © 2011-2022 走看看