欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android拖動條的實現(xiàn)代碼

 更新時間:2017年09月29日 08:46:10   作者:PeterRabbit49  
這篇文章主要為大家詳細介紹了Android拖動條的實現(xiàn)代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了Android拖動條的具體代碼,供大家參考,具體內(nèi)容如下

activity_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 xmlns:app="http://schemas.android.com/apk/res-auto" 
 xmlns:tools="http://schemas.android.com/tools" 
 android:layout_width="match_parent" 
 android:layout_height="match_parent" 
 tools:context="com.amy.seekbartest.MainActivity"> 
 
 <TextView 
  android:id="@+id/textView1" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content" 
  android:text="當(dāng)前值:50" 
  android:textSize="16sp" 
  android:paddingTop="40dp" 
  android:paddingLeft="15dp" 
  tools:layout_editor_absoluteY="0dp" 
  tools:layout_editor_absoluteX="0dp" /> 
 <!-- 拖動條 --> 
 <SeekBar 
  android:id="@+id/seekBar1" 
  android:layout_height="wrap_content" 
  android:max="100" 
  android:layout_width="match_parent" 
  android:progress="50" 
  android:paddingTop="10dp" 
  tools:layout_editor_absoluteY="0dp" 
  tools:layout_editor_absoluteX="32dp" /> 
</android.support.constraint.ConstraintLayout> 

MainActivity.java

package com.amy.seekbartest; 
 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.SeekBar; 
import android.widget.TextView; 
import android.widget.Toast; 
 
public class MainActivity extends AppCompatActivity { 
 
 private SeekBar seekBar;//拖動條 
 @Override 
 protected void onCreate(Bundle savedInstanceState) { 
  super.onCreate(savedInstanceState); 
  setContentView(R.layout.activity_main); 
  final TextView result = (TextView) findViewById(R.id.textView1); 
  seekBar = (SeekBar) findViewById(R.id.seekBar1); 
  seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { 
   @Override 
   public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { 
    result.setText("當(dāng)前值:"+progress); 
   } 
 
   @Override 
   public void onStartTrackingTouch(SeekBar seekBar) { 
    Toast.makeText(MainActivity.this,"開始滑動",Toast.LENGTH_SHORT).show(); 
   } 
 
   @Override 
   public void onStopTrackingTouch(SeekBar seekBar) { 
    Toast.makeText(MainActivity.this,"結(jié)束滑動",Toast.LENGTH_SHORT).show(); 
   } 
  }); 
 } 
} 

效果圖:

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

相關(guān)文章

  • Android實現(xiàn)藍牙(BlueTooth)設(shè)備檢測連接

    Android實現(xiàn)藍牙(BlueTooth)設(shè)備檢測連接

    這篇文章主要為大家詳細介紹了Android實現(xiàn)藍牙(BlueTooth)設(shè)備檢測連接,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-11-11
  • Android編程之圖片顏色處理方法

    Android編程之圖片顏色處理方法

    這篇文章主要介紹了Android編程之圖片顏色處理方法,涉及Android針對圖片的顏色值、飽和度、透明度等處理技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-10-10
  • 詳解Android過濾emoji表情正則表達式

    詳解Android過濾emoji表情正則表達式

    這篇文章主要介紹了Android過濾emoji表情正則表達式,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2018-06-06
  • Android實現(xiàn)長圖文截圖功能實例代碼

    Android實現(xiàn)長圖文截圖功能實例代碼

    這篇文章主要給大家介紹了關(guān)于Android實現(xiàn)長圖文截圖功能的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-11-11
  • Android數(shù)據(jù)庫操作工具類分享

    Android數(shù)據(jù)庫操作工具類分享

    這篇文章主要為大家詳細介紹了Android數(shù)據(jù)庫操作工具類的相關(guān)代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-10-10
  • 詳解android shape的使用總結(jié)

    詳解android shape的使用總結(jié)

    在Android程序開發(fā)中,我們經(jīng)常會去用到Shape這個東西去定義各種各樣的形狀,本篇文章主要介紹了android shape的使用,有興趣的可以一起了解一下。
    2016-12-12
  • Android編程解析XML方法詳解(SAX,DOM與PULL)

    Android編程解析XML方法詳解(SAX,DOM與PULL)

    這篇文章主要介紹了Android編程解析XML方法,結(jié)合實例形式詳細分析了Android解析XML文件的常用方法與相關(guān)實現(xiàn)技巧,需要的朋友可以參考下
    2016-01-01
  • android實現(xiàn)簡單底部導(dǎo)航欄

    android實現(xiàn)簡單底部導(dǎo)航欄

    這篇文章主要為大家詳細介紹了android實現(xiàn)簡單底部導(dǎo)航欄,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • 分析Android Activity的啟動過程

    分析Android Activity的啟動過程

    這篇文章主要介紹了分析Android Activity的啟動過程的相關(guān)資料,需要的朋友可以參考下
    2017-07-07
  • Eclipse NDK遷移到Android Studio的方法示例

    Eclipse NDK遷移到Android Studio的方法示例

    本篇文章主要介紹了Eclipse NDK遷移到Android Studio的方法示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-03-03

最新評論