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>
     


  • 相关阅读:
    2019 牛客多校第五场 B generator 1
    POJ 1797 Heavy Transportation
    POJ 3352 Road Construction
    POJ 2553 The Bottom of a Graph
    POJ 1236 Network of Schools
    POJ 1144 Network
    POJ 3761 Bubble Sort
    2019 牛客多校第三场 B Crazy Binary String
    2019 牛客多校第三场 H Magic Line
    Codeforces Round #592 (Div. 2)
  • 原文地址:https://www.cnblogs.com/tt_mc/p/1740836.html
Copyright © 2011-2022 走看看