源码简介
验证码相关: 1、发送短信验证码按钮的倒计时 2、按钮的并行监听 3、finish之后,后台线程依旧进行计时 【附注:】此源码与之前 子豪 的机制完全不一样,因此不是重复代码,可以放心下载!
源码截图
源码片段:
- public class TestMainActivity extends Activity implements OnClickListener {
- private MyCodeButton v;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- v = (MyCodeButton) findViewById(R.id.button1);
- v.onCreate(savedInstanceState);
- v.setTextAfter("s后重新获取").setTextBefore("获取验证码").setLenght(60 * 1000);
- v.setOnClickListener(this);
- }
- @Override
- public void onClick(View v) {
- // TODO Auto-generated method stub
- Toast.makeText(TestMainActivity.this, "并行处理点击事件...",
- Toast.LENGTH_SHORT).show();
- }
- @Override
- protected void onDestroy() {
- // TODO Auto-generated method stub
- v.onDestroy();
- super.onDestroy();
- }
- }