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

Android SeekBar實現(xiàn)滑動條效果

 更新時間:2018年07月20日 12:11:15   作者:周田的博客備份  
這篇文章主要為大家詳細介紹了Android SeekBar實現(xiàn)滑動條效果,可以改變并顯示當前進度的拖動,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了Android SeekBar實現(xiàn)滑動條效果的具體代碼,供大家參考,具體內(nèi)容如下

SeekBar是ProgressBar的一個子類,下面我們用一個可以改變并顯示當前進度的拖動條例子來演示一下它的使用:

1、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"> 
  <SeekBar android:id="@+id/SeekBar01" android:layout_width="245px" 
    android:layout_height="25px" android:paddingLeft="16px" 
    android:paddingRight="15px" android:paddingTop="5px" 
    android:paddingBottom="5px" android:progress="0" android:max="0" 
    android:secondaryProgress="0" /> 
  <TextView android:layout_width="fill_parent" 
    android:layout_height="wrap_content" android:text="@string/hello" 
    android:id="@+id/TextView01" /> 
</LinearLayout> 

2、java:

package com.esri.arcgis.sample; 
 
import android.app.Activity; 
import android.os.Bundle; 
import android.widget.SeekBar; 
import android.widget.SeekBar.OnSeekBarChangeListener; 
import android.widget.TextView; 
import android.widget.Toast; 
 
public class AndroidSeekBar extends Activity { 
  /** Called when the activity is first created. */ 
  @Override 
  public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
 
    // 找到拖動條和文本框 
    final SeekBar sb = (SeekBar) findViewById(R.id.SeekBar01); 
    final TextView tv1 = (TextView) findViewById(R.id.TextView01); 
 
    // 設(shè)置拖動條的初始值和文本框的初始值 
    sb.setMax(100); 
    sb.setProgress(30); 
    tv1.setText("當前進度:" + sb.getProgress()); 
 
    // 設(shè)置拖動條改變監(jiān)聽器 
    OnSeekBarChangeListener osbcl = new OnSeekBarChangeListener() { 
 
      @Override 
      public void onProgressChanged(SeekBar seekBar, int progress, 
          boolean fromUser) { 
        tv1.setText("當前進度:" + sb.getProgress()); 
        Toast.makeText(getApplicationContext(), "onProgressChanged", 
            Toast.LENGTH_SHORT).show(); 
      } 
 
      @Override 
      public void onStartTrackingTouch(SeekBar seekBar) { 
        Toast.makeText(getApplicationContext(), "onStartTrackingTouch", 
            Toast.LENGTH_SHORT).show(); 
      } 
 
      @Override 
      public void onStopTrackingTouch(SeekBar seekBar) { 
        Toast.makeText(getApplicationContext(), "onStopTrackingTouch", 
            Toast.LENGTH_SHORT).show(); 
      } 
 
    }; 
 
    // 為拖動條綁定監(jiān)聽器 
    sb.setOnSeekBarChangeListener(osbcl); 
 
  } 
} 

3、運行程序:

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

相關(guān)文章

最新評論

玉山县| 镇远县| 会理县| 胶南市| 会泽县| 芒康县| 义乌市| 曲阳县| 汝城县| 临海市| 通河县| 泰安市| 农安县| 梓潼县| 苍南县| 呈贡县| 文成县| 荔浦县| 镇巴县| 通州区| 柏乡县| 东乌珠穆沁旗| 嘉禾县| 江津市| 当阳市| 来凤县| 淮南市| 综艺| 出国| 大姚县| 阳谷县| 廊坊市| 如东县| 普洱| 南江县| 噶尔县| 财经| 翁牛特旗| 西乡县| 绵阳市| 盐亭县|