zoukankan      html  css  js  c++  java
  • 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);
        }  

    }  

    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>

    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>
     


  • 相关阅读:
    Web应用Word生成
    记 Ubuntu14.04 Monodevelop 安装的两个问题
    CSDN上下载的一些关于Android程序调用Webservice执行不成功的问题
    Binary Search Tree Iterator
    算法之贪心算法
    《SAS编程与数据挖掘商业案例》学习笔记之十七
    数据库设计之半结构化存储
    Timus 1446. Sorting Hat 分类问题
    WebGL on iOS8 最终等到了这一天
    仿netty线程池简化版本
  • 原文地址:https://www.cnblogs.com/tt_mc/p/1740836.html
Copyright © 2011-2022 走看看