MainActivity.java
package com.example.mars_2400_seekbar;import androID.support.v7.app.ActionBaractivity;import androID.support.v7.app.Actionbar;import androID.support.v4.app.Fragment;import androID.app.Activity;import androID.os.Bundle;import androID.vIEw.LayoutInflater;import androID.vIEw.Menu;import androID.vIEw.MenuItem;import androID.vIEw.VIEw;import androID.vIEw.VIEwGroup;import androID.Widget.Seekbar;import androID.Widget.Seekbar.OnSeekbarchangelistener;import androID.Widget.TextVIEw;import androID.os.Build;public class MainActivity extends Activity implements OnSeekbarchangelistener { private TextVIEw tv; private Seekbar sb; @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_main); tv = (TextVIEw) findVIEwByID(R.ID.textVIEw1); sb = (Seekbar) findVIEwByID(R.ID.seekbar); sb.setonSeekbarchangelistener(this); } @OverrIDe public voID onProgressChanged(Seekbar seekbar,int progress,boolean fromUser) { // Todo auto-generated method stub tv.setText("Progress is " + progress + (fromUser ? " Trigger" : " Nontrigger") + " by user."); } @OverrIDe public voID onStartTrackingtouch(Seekbar seekbar) { // Todo auto-generated method stub System.out.println("onStart-->"+seekbar.getProgress()); } @OverrIDe public voID onStopTrackingtouch(Seekbar seekbar) { // Todo auto-generated method stub System.out.println("onStop-->"+seekbar.getProgress()); } @OverrIDe public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main,menu); return true; }}
activity_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" > <TextVIEw androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:ID="@+ID/textVIEw1"/><Seekbar androID:ID="@+ID/seekbar" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content"/> </linearLayout>
以上就是小编为大家带来的androID之Seekbar控件用法详解的全部内容了,希望对大家有所帮助,多多支持编程小技巧~
总结以上是内存溢出为你收集整理的android之SeekBar控件用法详解全部内容,希望文章能够帮你解决android之SeekBar控件用法详解所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)