new CountDownTimer(30000, 1000) {
public void onTick(long millisUntilFinished) {
mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
}
public void onFinish() {
mTextField.setText("done!");
}
}.start();
答案 0 :(得分:1)
如果您拥有任何Android平台jar(#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include "display.h"
#include "move.h"
#include "place.h"
#define MAX 799
#define DEAD 0
#define TRUE 1
#define FALSE 0
int main()
{
//initialize variables
struct pos { //positions
int fx[MAX];
int fy[MAX];
int tx;
int ty;
int jx;
int jy;
} pos;
struct score { //scores
int move;
int F;
int J;
} score;
int d,q,i,k,f,followc;
int p;
char *z="Number of Jujus collectd ";
char *y="The number of followers ";
do {
score.F=score.J = score.move = 0;
i=k=f=followc=0;
draw_map();
place(&pos.tx,&pos.ty);
sleep(1);
draw_symbol(pos.tx, pos.ty, 'S');
place(&pos.jx, &pos.jy);
display_score(score.move);
debug_wds(5,z);
debug_wds(8,y);
debug_num(6,score.J);
debug_num(9,score.F);
while(d!=DEAD && q != 'q' && q != 'Q')
{
pos.fx[i]=pos.tx; //store timmy's position in follower
pos.fy[i]=pos.ty; //store timmy's position in follower
draw_symbol(pos.jx, pos.jy, '$');
display_score(score.move);
debug_wds(5,z);
debug_num(6,score.J);
debug_wds(8,y);
debug_num(9,score.F);
q = move(&pos.tx, &pos.ty); //move timmy
score.move++;
draw_symbol(pos.tx,pos.ty,'S'); //update timmy's position
if((pos.tx ==pos.jx)&&(pos.ty == pos.jy)) //if timmy collects a juju
{
score.J++; //update juju score
score.F++; //update follower score
display_score(score.move);
place(&pos.jx,&pos.jy);
followc++; //update follower count
}
for (f=0,k=i+1-followc; f<followc; f++,k++) //check to see if timmy is same position as followers
{
if(pos.tx==pos.fx[k]&&pos.ty==pos.fy[k])
{
d=DEAD;
}
draw_symbol(pos.fx[k],pos.fy[k],'O'); //draw followers
}
i++;
}
clear_screen();
printf("Number of Jujus = %d\n", score.J);
printf("Ripperoni... You really need to update your server(s)..*___*\n");
printf("Enter 1 to keep playing\n");
scanf("%d",&p);
} while(p==1);
}
),就像在外部库中一样,您可以在班级中导入android.jar
。
导入后,您可以在类中创建CountDownTimer的对象:
android.os.CountDownTimer
答案 1 :(得分:0)
您必须导入android.os.CountDownTimer
。
试试这个:
import android.os.CountDownTimer;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
.....................
..............................
new CountDownTimer(30000, 1000) {
public void onTick(long millisUntilFinished) {
mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
}
public void onFinish() {
mTextField.setText("done!");
}
}.start();
.....................
..............................
}
}