倒计时
来源:互联网 发布:5s优化设置 编辑:程序博客网 时间:2024/06/05 15:32
public class MainActivity extends AppCompatActivity { private Handler handler=new Handler(); private SharedPreferences sharedPreferences; private SharedPreferences.Editor editor; private boolean First; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); sharedPreferences=getSharedPreferences("First",MODE_PRIVATE); First=sharedPreferences.getBoolean("First",true); if(First) { handler.postDelayed(new Runnable() { @Override public void run() { Intent intent = new Intent(MainActivity.this, Main2Activity.class); startActivity(intent); } }, 2000); }else { Intent intent = new Intent(MainActivity.this, Main2Activity.class); startActivity(intent); } editor = sharedPreferences.edit(); editor.putBoolean("First",false); editor.commit(); }}<---------------------------------------------------------------------------------------------->public class Main2Activity extends AppCompatActivity { private TextView textView; private int time = 5; private Handler handler = new Handler(); private Runnable runnable = new Runnable() { @Override public void run() { time--; handler.postDelayed(this, 1000); textView.setText("跳转" + time + "秒"); if (time == 0) { Intent intent = new Intent(Main2Activity.this, Main3Activity.class); startActivity(intent); finish(); } else { textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Main2Activity.this, Main3Activity.class); startActivity(intent); handler.removeCallbacks(runnable); finish(); } }); } } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); textView = (TextView) findViewById(R.id.t1); handler.postDelayed(runnable, 0); }}
阅读全文
0 0
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时、、、、、
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 文本编辑器
- linux 下 采用CMake 方式开发php扩展(一)
- hive最基本命令
- 数据同步sql语句
- 利用word2vec对关键词进行聚类
- 倒计时
- dubbo小试
- C++:auto_ptr智能指针的用法
- Android实现https项目实战
- java http接口
- 抽象类和接口的区别
- association,aggregation,composition差别
- EF6 在原有数据库中使用 CodeFirst 总复习(二、新的需求,简单修改原有表)
- Android Studio中的字体设置