Android's Seekbar control usage _android

Source: Internet
Author: User

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 stub
      System.out.println ("onstart-->" +seekbar.getprogress ());
  	      @Override public void Onstoptrackingtouch (SeekBar SeekBar) {//TODO auto-generated stub
      System.out.println ("onstop-->" +seekbar.getprogress ()); @Override public boolean Oncreateoptionsmenu (Menu menu) {//Inflate the menu; This adds items to the action B
    Ar 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"
  Wrap_content "
  android:id=" @+id/textview1/>

<seekbar android:id= "@+id/seekbar"
  android: Layout_width= "Fill_parent"
  android:layout_height= "wrap_content"/>
 </LinearLayout>

The above is a small series for everyone to bring the Android Seekbar control usage details of the full content, I hope to help you, a lot of support cloud Habitat Community ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.