现在的位置: 首页 > 综合 > 正文

android seekbar

2013年10月14日 ⁄ 综合 ⁄ 共 2013字 ⁄ 字号 评论关闭
  • <?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">   
  •     <SeekBar android:id="@+id/SeekBar01" android:layout_width="fill_parent"  
  •         android:layout_height="wrap_content" android:max="100"  
  •         android:progress="50" android:secondaryProgress="100"></SeekBar>   
  •     <TextView android:id="@+id/TextView1" android:layout_width="fill_parent"  

            android:layout_height="wrap_content" android:text="" />   

        <TextView android:id="@+id/TextView2" android:layout_width="fill_parent"  

            android:layout_height="wrap_content" android:text="" />   

    </LinearLayout>

     

     

    1. package com.Aina.Android;   
    2.   
    3. import android.app.Activity;   
    4. import android.os.Bundle;   
    5. import android.widget.SeekBar;   
    6. import android.widget.TextView;   
    7.   
    8. public class Test_SeekBar extends Activity implements SeekBar.OnSeekBarChangeListener{
        
    9.     /** Called when the activity is first created. */  
    10.     private SeekBar seekBar;   
    11.     private TextView textView1,textView2;   
    12.     @Override  
    13.     public void onCreate(Bundle savedInstanceState) {   
    14.         super.onCreate(savedInstanceState);   
    15.         setContentView(R.layout.main);   
    16.         seekBar = (SeekBar) this.findViewById(R.id.SeekBar01);   
    17.         textView1 = (TextView) this.findViewById(R.id.TextView1);   
    18.         textView2 = (TextView) this.findViewById(R.id.TextView2);   
    19.         seekBar.setOnSeekBarChangeListener(this);//添加事件监听
        
    20.     }   
    21.     //拖动中   
    22.     @Override  
    23.     public void onProgressChanged(SeekBar seekBar, int progress,   
    24.             boolean fromUser) {   
    25.         this.textView1.setText("当前值:"+progress);   
    26.            
    27.     }   
    28.     //开始拖动   
    29.     @Override  
    30.     public void onStartTrackingTouch(SeekBar seekBar) {   
    31.         this.textView2.setText("拖动中...");   
    32.            
    33.     }   
    34.     //结束拖动   
    35.     @Override  
    36.     public void onStopTrackingTouch(SeekBar seekBar) {   
    37.         this.textView2.setText("拖动完毕");   
    38.            
    39.     }   
    40. }  
  • 抱歉!评论已关闭.