Advanced Controls "Android 6"-Timers (Chronometer), tags (tabhost)

Source: Internet
Author: User
Tags getbase

Timers (chronometer)

Method

Describe

Public chronometer (context context) "Construction method"

Create a Chronometer Object

Public long getbase ()

Set a base time that you can do by completing

public void SetFormat (String format)

Set display format

Public long getbase ()

Returns the set base time

Public String GetFormat ()

Returns the display format of the setting

public void Start ()

Start timing

public void Stop ()

Stop timing

public void Setonchronometerticklistener (

Chronometer.onchronometerticklistener listener)

Setting a listener event for timing changes

<chronometerAndroid:id= "@+id/chro"Android:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"/><LinearLayoutAndroid:layout_width= "Fill_parent"Android:layout_height= "Wrap_content">         <ButtonAndroid:id= "@+id/cbtstart"Android:text= "Start"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_weight= "1"/>          <ButtonAndroid:id= "@+id/cbtstop"Android:text= "End"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_weight= "1"/></LinearLayout>
chronometerLabel (Tabhost) Way One: direct inheritance tabactivity class

Tab.xml

1  Public classTabhostextendstabactivity {2    protected voidonCreate (Bundle savedinstancestate) {3        Super. OnCreate (savedinstancestate);4Tabhost Tab=gettabhost ();//gets the object of the Tabhost class5Layoutinflater. From ( This).6Inflate (R.layout.tab,//defining the Layout manager for Transformations7Tab.gettabcontentview (),//specify container for label additions8                 true);//instantiating components in the layout manager9       //OptionsTenTabspec Sp1=tab.newtabspec ("Tab1"); One         //set the label's caption, set the label's display content ASp1.setindicator ("option 1")). SetContent (R.ID.TTV01);  -Tab.addtab (SP1);//tab of the Set tab -          theTabspec Sp2=tab.newtabspec ("TaB2"); -Sp2.setindicator ("Option 2")). SetContent (r.id.ttv02); - Tab.addtab (SP2); -          +Tabspec Sp3=tab.newtabspec ("Tab3"); -Sp3.setindicator ("option 3")). SetContent (r.id.ttv03); + Tab.addtab (SP3); A     } at}
Label CONTROLS: code examples

Tabhost.tabspec

Tabhost class adds each option to add multiple Tabhost.tabspec the object,

This kind of thing Tabhost defines the inner class

Method Two: Define the component in the layout file

Use <TabHost> tags to make root tags

<Tabhostxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content">  <LinearLayoutAndroid:id= "@+id/tll01"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent">            <ImageViewandroid:src= "@drawable /A"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"/>          <TextViewAndroid:text= "hahaha"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"/>  </LinearLayout>  <LinearLayoutAndroid:id= "@+id/tll02"android:orientation= "vertical"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent">            <ImageViewandroid:src= "@drawable/b"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"/>          <TextViewAndroid:text= "hahaha"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"/>  </LinearLayout></Tabhost>
Label control: XML Code
1 protected voidonCreate (Bundle savedinstancestate) {2     Super. OnCreate (savedinstancestate);3Tabhost tab=gettabhost ();4Layoutinflater.from ( This).5Inflate (r.layout.tab0,//defining the Layout manager for Transformations6Tab.gettabcontentview (),//specify container for label additions7         true);//instantiating components in the layout manager8     //Options9Tabspec Sp1=tab.newtabspec ("Tab1");Ten     //set the label's caption, set the label's display content OneSp1.setindicator ("option 1")). SetContent (R.ID.TLL01);  ATab.addtab (SP1);//tab of the Set tab -          -Tabspec Sp2=tab.newtabspec ("TaB2"); theSp2.setindicator ("Option 2")). SetContent (R.ID.TLL02); - Tab.addtab (SP2); -}
Label control: Java code

Advanced Controls "Android 6"-Timers (Chronometer), tags (tabhost)

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.