原创内容,转载请注明原文网址:http://homeqin.cn/a/wenzhangboke/jishutiandi/Android/2019/0602/525.html
	androidSeekBar 
	拖动条: 
	布局文件: 
	Java代码  收藏代码
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
	    android:id="@+id/gridView"  
	    android:orientation="vertical"  
	    android:layout_width="fill_parent"  
	    android:layout_height="fill_parent" >  
	    <EditText  
	        android:id="@+id/font"  
	        android:layout_width="match_parent"  
	        android:layout_height="300dp"  
	        android:ems="10"  
	        android:lines="5"  
	        android:text="看我大小,别翻眼..."  
	        android:inputType="textMultiLine" >  
	        <requestFocus />  
	    </EditText>  
	    <SeekBar   
	        android:id="@+id/seekBar"  
	        android:layout_width="fill_parent"  
	        android:layout_height="wrap_content"  
	        android:max="100"  
	        android:scrollbarStyle="insideOverlay"  
	        android:progress="1"  
	        />  
	</LinearLayout>  
	主程序入口: 
	Java代码  收藏代码
	package com.example.advancedview;  
	import android.app.Activity;  
	import android.os.Bundle;  
	import android.widget.EditText;  
	import android.widget.SeekBar;  
	import android.widget.Toast;  
	import android.widget.SeekBar.OnSeekBarChangeListener;  
	/** 
	 * SeekBar 功能演示, 拖动来改变字体的大小 
	 * @author Administrator 
	 * 
	 */  
	public class SeekBarActivity extends Activity {  
	    //声明变量  
	    private SeekBar seekBar;  
	    private EditText font;  
	    protected void onCreate(Bundle savedInstanceState) {  
	        super.onCreate(savedInstanceState);  
	        setContentView(R.layout.seek_bar_layout);  
	        font = (EditText) findViewById(R.id.font);  
	        seekBar = (SeekBar) findViewById(R.id.seekBar);  
	        seekBar.setOnSeekBarChangeListener(seekListerner);  
	    }  
	    // 拖动条事件  
	    private OnSeekBarChangeListener seekListerner = new OnSeekBarChangeListener() {  
	        // 拖动条停止执行  
	        public void onStopTrackingTouch(SeekBar seekBar) {  
	            Toast.makeText(SeekBarActivity.this, "停止了:"+seekBar.getProgress(), 1000).show();  
	        }  
	        // 开始执行  
	        public void onStartTrackingTouch(SeekBar seekBar) {  
	            Toast.makeText(SeekBarActivity.this, "开始了:"+seekBar.getProgress(), 1000).show();  
	        }  
	        // 拖动中  
	        public void onProgressChanged(SeekBar seekBar, int progress,  
	                boolean fromUser) {  
	            font.setTextSize(progress); // 改变字体的大小  
	        }  
	    };  
	}  
上篇:上一篇:获取Android建筑唯独标识(唯独序列号)
下篇:下一篇:android service 后台执行按时使命

