Android implements a simple countdown function

Source: Internet
Author: User

Tag:android    countdown    

public class mainactivity extends activity {private textview textview; private button but1;private int count=0;     @Override      protected void oncreate (bundle savedinstancestate)  {         super.oncreate (savedinstancestate);         Setcontentview (R.layout.activity_main);         textview= (TextView) Findviewbyid (R.id.mytextview);                 but1= (Button) Findviewbyid (R.ID.BUT1);         but1  B=NEW BUT1 ();         but1.setonclicklistener (b);             }     @Override      public boolean Oncreateoptionsmenu (Menu menu)  {        getmenuinflater (). Inflate (R.menu.main, menu);        return true;     }     @Override     public boolean  Onoptionsitemselected (Menuitem item)  {        int id  = item.getitemid ();        if  (id ==  R.id.action_settings)  {            return  true;        }         return super.onoptionsitemselected (item);     }    CLASS BUT1  implements onclicklistener{@Overridepublic  void onclick (view v)  {new  Countdowntimer (30000,1000)  {@Overridepublic &Nbsp;void ontick (long millisuntilfinished)  {textview.settext ("Please wait 30 seconds ("  +  millisuntilfinished / 1000 +  "),   @Overridepublic  void onfinish ()  {toast.maketext (Getapplicationcontext (),  "Countdown End",      toast.length_short). Show ();}}. Start ();}         }                     }


This article is from the "Java White Battlefield" blog, be sure to keep this source http://8023java.blog.51cto.com/10117207/1657588

Android implements a simple countdown function

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.