十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
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{ @Override public void onClick(View v) { new CountDownTimer(30000,1000) { @Override public void onTick(long millisUntilFinished) { textview.setText("请等待30秒(" + millisUntilFinished / 1000 + ")..."); } @Override public void onFinish() { Toast.makeText(getApplicationContext(), "倒计时结束", Toast.LENGTH_SHORT).show(); } }.start(); } } }