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)