• ANDROID_MARS学习笔记_S01_012_SeekBar


    1.xml

     1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     2     xmlns:tools="http://schemas.android.com/tools"
     3     android:layout_width="match_parent"
     4     android:layout_height="match_parent"
     5     android:paddingBottom="@dimen/activity_vertical_margin"
     6     android:paddingLeft="@dimen/activity_horizontal_margin"
     7     android:paddingRight="@dimen/activity_horizontal_margin"
     8     android:paddingTop="@dimen/activity_vertical_margin"
     9     tools:context=".MainActivity" >
    10 
    11     <SeekBar 
    12         android:id="@+id/firstSeekBar"
    13         android:layout_width="match_parent"
    14         android:layout_height="wrap_content"
    15         android:max="100"
    16         />
    17 </RelativeLayout>

    2.java

     1 package com.marschen.s01_e18_seekbar;
     2 
     3 import android.app.Activity;
     4 import android.os.Bundle;
     5 import android.view.Menu;
     6 import android.widget.SeekBar;
     7 import android.widget.SeekBar.OnSeekBarChangeListener;
     8 
     9 public class MainActivity extends Activity {
    10 
    11     private SeekBar seekBar;
    12     @Override
    13     protected void onCreate(Bundle savedInstanceState) {
    14         super.onCreate(savedInstanceState);
    15         setContentView(R.layout.activity_main);
    16         
    17         seekBar = (SeekBar)findViewById(R.id.firstSeekBar);
    18         seekBar.setProgress(30);
    19         seekBar.setSecondaryProgress(50);
    20         
    21         SeekBarListener listener = new SeekBarListener();
    22         seekBar.setOnSeekBarChangeListener(listener);
    23     }
    24     
    25     class SeekBarListener implements OnSeekBarChangeListener{
    26 
    27         /**
    28          * seekBar 该对象指的是触发了监听器的SeekBar对象
    29          * progress 指的是当前SeekBar的进度
    30          * fromUser 
    31          */
    32         @Override
    33         public void onProgressChanged(SeekBar SeekBar, int progress, boolean fromUser) {
    34             System.out.println("progress:" + progress + ",fromUser:" + fromUser);
    35         }
    36 
    37         @Override
    38         public void onStartTrackingTouch(SeekBar seekBar) {
    39             System.out.println("onStart");
    40         }
    41 
    42         @Override
    43         public void onStopTrackingTouch(SeekBar seekBar) {
    44             System.out.println("onStop");
    45         }
    46         
    47     }
    48 
    49     @Override
    50     public boolean onCreateOptionsMenu(Menu menu) {
    51         // Inflate the menu; this adds items to the action bar if it is present.
    52         getMenuInflater().inflate(R.menu.main, menu);
    53         return true;
    54     }
    55 
    56 }
  • 相关阅读:
    centos6.5下的mysql5.6.30安装
    mysql常见错误
    fpm打包redis3.0.7
    centos6.5安装fpm打包工具
    centos6.5安装flume
    centos6.5 安装mono
    利用rsyslog 对linux 操作进行审计
    CentOS7修改服务器主机名方法
    CentOS 7 修改网卡名称为eth
    keepalived配置日志
  • 原文地址:https://www.cnblogs.com/shamgod/p/5186987.html
Copyright © 2020-2023  润新知