国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Android > 正文

Android拖動(dòng)條的實(shí)現(xiàn)代碼

2019-10-22 18:26:58
字體:
供稿:網(wǎng)友

本文實(shí)例為大家分享了Android拖動(dòng)條的具體代碼,供大家參考,具體內(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" />  <!-- 拖動(dòng)條 -->  <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;//拖動(dòng)條  @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,"開始滑動(dòng)",Toast.LENGTH_SHORT).show();    }     @Override    public void onStopTrackingTouch(SeekBar seekBar) {     Toast.makeText(MainActivity.this,"結(jié)束滑動(dòng)",Toast.LENGTH_SHORT).show();    }   });  } } 

效果圖:

Android,拖動(dòng)條

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持VEVB武林網(wǎng)。


注:相關(guān)教程知識(shí)閱讀請移步到Android開發(fā)頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 从化市| 孟村| 禄劝| 乐都县| 涿鹿县| 普格县| 长丰县| 延津县| 重庆市| 海伦市| 衡阳市| 资阳市| 额尔古纳市| 新巴尔虎左旗| 昂仁县| 镇赉县| 临颍县| 安多县| 登封市| 合阳县| 永善县| 德格县| 吉木萨尔县| 新绛县| 专栏| 瓦房店市| 万山特区| 邓州市| 彩票| 江阴市| 通许县| 道孚县| 峨边| 林甸县| 迁安市| 滦南县| 峨边| 西和县| 乳山市| 拜泉县| 汉沽区|