Android Chinese API (26) -- seekbar

Source: Internet
Author: User

Preface

This chapter content is Android. widget. seekbar, translated from madgoat, welcome to visit his blog: http://madgoat.cn, thanks again madgoat! I look forward to your participation in Android API Chinese translation, contact me over140@gmail.com.

 

Statement

You are welcome to repost, but please keep the original source of the article :)

Blog Garden: http://www.cnblogs.com/

Android Chinese translation group: http://www.cnblogs.com/over140/

 

Body

I. Structure

    Public class seekbar extends absseekbar

 

Java. Lang. Object

Android. View. View

Android. widget. progressbar

Android. widget. absseekbar

Android. widget. seekbar

 

 

Ii. Overview

    

Seekbar is an extension of progressbar, and a scalable thumb is added to it (Note: it is the movable icon ). You can touch thumb and drag it left or right, or you can use the arrow keys to set the current progress level. We do not recommend placing widgets that can obtain the focus on the left or right side of the seekbar.

Seekbar can be appended with a seekbar. onseekbarchangelistener to receive user operation notifications.

    

Iii. Internal class

Interface seekbar. onseekbarchangelistener

A callback function is used to notify the client when the progress level changes.

 

Iv. xml attributes

Attribute name

Description

Android: thumb

Thumb drawn on seekbar (the icon that can be dragged)

 

V. Public Methods

Public void setonseekbarchangelistener (seekbar. onseekbarchangelistener L)

Set a listener to receive notifications when the seekbar progress changes. It also provides notifications when you start or stop a touch gesture on seekbar.

Parameters

L notification listener of seekbar

See

Seekbar. onseekbarchangelistener

 

Vi. Supplement

6.1 article link

Create a vertical seekbar in Android

Android uidesign seekbar dragging bar usage

 

6.2 Sample Code

6.2.1 Java File

Public class seekbardemo extends activity {
@ Override
Protected void oncreate (bundle savedinstancestate ){
Super. oncreate (savedinstancestate );
Setcontentview (R. layout. seekbardemo );

Final seekbar seekbar1 = (seekbar) This. findviewbyid (R. Id. seekbar1 );
Seekbar1.setonseekbarchangelistener (New onseekbarchangelistener (){
@ Override
Public void onstoptrackingtouch (seekbar ){

}

@ Override
Public void onstarttrackingtouch (seekbar ){

}

@ Override
Public void onprogresschanged (seekbar, int progress,
Boolean fromuser ){
Toast. maketext (seekbardemo. This,
String. valueof (seekbar1.getprogress ()),
Toast. length_short). Show ();
}
});
}
}

6.2.1 XML file

<? XML version = "1.0" encoding = "UTF-8"?>
<Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "fill_parent" Android: layout_height = "fill_parent"
>
<Seekbar Android: Id = "@ + ID/seekbar1" Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content" Android: max = "100"
> </Seekbar>
</Linearlayout>

 

End

Thanks again for madgoat's hard work!

 

 

Related Article

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.