最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android seekbar實(shí)現(xiàn)可拖動進(jìn)度條

 更新時間:2021年01月27日 12:04:03   作者:「已注銷」  
這篇文章主要為大家詳細(xì)介紹了Android seekbar實(shí)現(xiàn)可拖動進(jìn)度條,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android seekbar實(shí)現(xiàn)可拖動進(jìn)度條的具體代碼,供大家參考,具體內(nèi)容如下

SeekBar通過滑塊的位置來標(biāo)識數(shù)值 允許用戶通過拖動滑塊來改變進(jìn)度值的大小

控件:SeekBar
           兩個TextView 顯示狀態(tài)

實(shí)現(xiàn)SeekBar.OnSeekBarChangeListener接口 對事件進(jìn)行監(jiān)聽

xml文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical">
 
 <SeekBar
   android:id="@+id/seekBar"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:max="100"
   android:progress="50" />
 
 <TextView
   android:id="@+id/tv1"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
    />
 
 <TextView
   android:id="@+id/tv2"
   android:layout_width="match_parent"
   android:layout_height="wrap_content" />
 
</LinearLayout>

MainActivity:

package com.example.lenovo.seekbar;
 
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.TextView;
 
public class MainActivity extends Activity implements SeekBar.OnSeekBarChangeListener {
 
  private SeekBar seekBar;
  private TextView tv1;
  private TextView tv2;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    tv1=findViewById(R.id.tv1);
    tv2=findViewById(R.id.tv2);
    seekBar=findViewById(R.id.seekBar);
    //設(shè)置監(jiān)聽器 監(jiān)聽數(shù)值改變情況
    seekBar.setOnSeekBarChangeListener(this);
  }
  //數(shù)值改變
  @Override
  public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    tv1.setText("正在拖動");
    tv2.setText("當(dāng)前數(shù)值:"+progress);
  }
  //開始拖動
  @Override
  public void onStartTrackingTouch(SeekBar seekBar) {
    tv1.setText("開始拖動");
  }
  //停止拖動
  @Override
  public void onStopTrackingTouch(SeekBar seekBar) {
    tv1.setText("停止拖動");
  }
}

效果圖:

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

两当县| 政和县| 宁安市| 岢岚县| 南涧| 肃宁县| 滁州市| 龙里县| 封丘县| 河北省| 双辽市| 苏州市| 洞口县| 邵东县| 内黄县| 杭锦后旗| 濮阳县| 兴和县| 安溪县| 新巴尔虎左旗| 新干县| 剑河县| 平舆县| 兴业县| 如东县| 林口县| 昌吉市| 罗定市| 岳西县| 台东市| 民县| 永吉县| 布尔津县| 岑溪市| 锡林浩特市| 蒲江县| 阿城市| 平顺县| 信丰县| 墨竹工卡县| 镇安县|