小编Pix*_*nch的帖子

Android - 希望应用程序每秒执行一次任务

我正在尝试让我的倒计时应用程序执行其更新我当前时间和日期TextView的功能,并每秒触发其MyOnItemSelectedListener,以便应用程序动态倒计时而不是仅在启动onCreate时.如果有一个更有效的方法然后快速解雇MyOnItemSelectedListener我会很感激批评.

public class TheCount extends Activity {
TextView description=null;
TextView dates=null;
TextView times=null;
TextView output=null;
TextView cDateDisplay=null;
TextView cTimeDisplay=null;
private int mYear;
private int mMonth;
private int mDay;
private int mHour;
private int mMinute;
private int mSecond;
CountdownHelper helper=null;
String countdownId=null;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.thecount);
    helper=new CountdownHelper(this);
    cTimeDisplay = (TextView)findViewById(R.id.lblCurTime);
    cDateDisplay = (TextView)findViewById(R.id.lblCurDate);

    final Calendar c = Calendar.getInstance();
    mYear = c.get(Calendar.YEAR);
    mMonth = c.get(Calendar.MONTH);
    mDay = c.get(Calendar.DAY_OF_MONTH);
    mHour = c.get(Calendar.HOUR_OF_DAY);
    mMinute = c.get(Calendar.MINUTE);
    mSecond = c.get(Calendar.SECOND); …
Run Code Online (Sandbox Code Playgroud)

android action timer handler

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

action ×1

android ×1

handler ×1

timer ×1