我有一个循环5每次用户单击5 textview创建一个添加到父视图。但是,如果我连续单击按钮(就像之前previos看停止)然后temp值超过0到4,并继续....我怎么能重置临时值(静态变量)内处理程序。如何重置android延迟处理程序中的一个静态变量android
// start of program.
static int temp = 0;
// button on click event
temp = 0;
for(k = 0; k < 5; k++){
new Handler().postDelayed(new Runnable() {
public void run() {
Animation a1 = new AlphaAnimation(0.00f, 1.00f);
a1.setDuration(350);
a1.setFillAfter(true);
TextView tv = new TextView(Main.this);
tv.setVisibility(View.INVISIBLE);
// tv.setText(emotionnames.get(temp)); //crashing here. index is 5 size is 5
Log.i("temp", Integer.toString(temp));
tv.setTextSize(32);
tv.setPadding(10, 0, 10, 0);
tv.clearAnimation();
tv.startAnimation(a1);
lhsv.addView(tv);
temp++;
}
}, 500 + 500 * k);
}
你是什么意思重置? – Altaaf 2012-02-15 08:15:45
喜欢使它成为零温度= 0 – Programmer 2012-02-15 08:17:09
不是100%确定你想要什么,但我修改了我的例子,给出一个可能的方式去指示!祝你好运 – Entreco 2012-02-16 09:22:56