Android implements the countdown jump on the pop-up page and the top right corner, and android jump

Source: Internet
Author: User

Android implements the countdown jump on the pop-up page and the top right corner, and android jump

:

The handler and CountDownTimer classes are used in the pop-up page. You also need to configure the theme of the Activity, which is android: Theme = "@ android: style/theme. noTitleBar. fullscreen "indicates the full screen topic.

Source code:

Package com. example. shanping; import java. lang. ref. weakReference; import com. example. shanping. myActivity. myCountDownTimer; import android. OS. bundle; import android. OS. countDownTimer; import android. OS. handler; import android. OS. message; import android. app. activity; import android. content. intent; import android. util. log; import android. view. menu; import android. widget. textView; public class MainActivity extends Activity {private MyCountDownTimer mc; private TextView TV; @ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_main); TV = (TextView) findViewById (R. id. textView1); mc = new MyCountDownTimer (3000,100 0); mc. start (); handler. postDelayed (new Runnable () {@ Override public void run () {Intent intent = new Intent (MainActivity. this, MyActivity. class); startActivity (intent); }}, 3000);} private Handler handler = new Handler (); /*** inherit CountDownTimer prevention *** override the methods onTick () and onFinish () of the parent class () */class MyCountDownTimer extends CountDownTimer {/***** @ param millisInFuture * indicates the total number of Countdown times in milliseconds. ** for example, millisInFuture = 1000 indicates 1 second. ** @ param countDownInterval * indicates interval: How many microseconds does one onTick method call? ** example: countDownInterval = 1000; indicates that onTick () **/public MyCountDownTimer (long millisInFuture, long countDownInterval) {super (millisInFuture, countDownInterval);} public void onFinish () is called every 1000 milliseconds () {TV. setText ("redirecting");} public void onTick (long millisUntilFinished) {TV. setText ("Countdown (" + millisUntilFinished/1000 + ")");}}}

 

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.