• SeekBar的基本使用方法


    a)         什么是SeekBar

    b)         使用SeekBar的步骤:

                                           i.              在布局文件当中声明SeekBar: <SekBar android:id=”@+id/seekbarld” android:layout_width=”fill_parent” android:layout_height=”wrap_content”/>

                                         ii.              定义一个OnSeekBarChangeListener: private class SeekBarListener implements SeekBar.OnSeekBarChangeListener{public void onProgressChanged(SeekBar seekBar,int progress,Boolean fromUser){System.out.println(progress);} public void onStartTrackingTouch(SeekBar seekBar){System.out.println(“start:=>”+seekBar.getProgress());} public void onStopTrackingTouch(SeekBar seekBar){System.out.println(“begin:=>”+seekBar.getProgress());}}

                                        iii.              SeekBar绑定监听器: seekBarSetOnSeekBarChangeListener(new SeekBarListener());

    案例项目:

    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"
        >
    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"
        />
        <SeekBar
         android:id="@+id/seekBarId"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         />
    </LinearLayout>
    SeekBarJsd.java:

    package com.jsd;

    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.SeekBar;

    /**
     * SeekBar Progress
     * @author Administrator
     *
     */
    public class SeekBarJsd extends Activity {
      
     private SeekBar seekBar = null;
     
     /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            
            seekBar = (SeekBar) findViewById(R.id.seekBarId);
            //设置该进度条的最大值,默认情况下为O
            seekBar.setMax(100);
            seekBar.setOnSeekBarChangeListener(seekBarListener);
        }
        
        /**
         * SeekBarListener 
         * 定义一个监听器,该监听器负责监听进度条进度的改变
         */
        private SeekBar.OnSeekBarChangeListener seekBarListener = new SeekBar.OnSeekBarChangeListener() {
      
         /**
          * 当用户结束对滑块滑动时,调用该方法
          */
      public void onStopTrackingTouch(SeekBar seekBar) {
       // TODO Auto-generated method stub
       System.out.println("stop: > "+seekBar.getProgress());
      }
      
      /**
       * 当用户开始滑动滑块时调用该方法
       */
      public void onStartTrackingTouch(SeekBar seekBar) {
       // TODO Auto-generated method stub
       System.out.println("start: => "+seekBar.getProgress());
      }
      
      /**
       * 当进度条发生变化时调用该方法
       */
      public void onProgressChanged(SeekBar seekBar, int progress,
        boolean fromUser) {
       // TODO Auto-generated method stub
       System.out.println(progress);
      }
     }

    图:
    }tu

  • 相关阅读:
    C#各版本新特性
    ubantu操作积累
    C# System.Net.Http.HttpClient使用说明
    IIS下VUE跳转
    融合主流的技术 分布式中间件+微服务+微架构架构
    论减少代码中return语句的骚操作
    shell脚本--多个代码库批量pull最新master代码
    SpringBoot单元测试
    Qt音视频开发36-USB摄像头解码qcamera方案
    Qt音视频开发35-Onvif图片参数
  • 原文地址:https://www.cnblogs.com/Gaojiecai/p/2181867.html
Copyright © 2020-2023  润新知