我有一個簡單的動畫附加到我創建的動態文本視圖,但我想要的是添加延遲時添加它們。請指導我如何做到這一點。添加延遲期間添加視圖在Android
LinearLayout ll = (LinearLayout)findViewById(R.id.ll);
final HorizontalScrollView hsv = new HorizontalScrollView(TestViewActivity.this);
LinearLayout lhsv = new LinearLayout(TestViewActivity.this);
Animation a1 = new AlphaAnimation(0.00f, 1.00f);
a1.setDuration(350);
a1.setFillAfter(true);
for(int k =0; k < 5; k++){
// may be some handler here but how ?
TextView tv = new TextView(TestViewActivity.this);
tv.setText("Text");
tv.setTextSize(42);
tv.setPadding(10, 0, 10, 0);
tv.setVisibility(View.INVISIBLE);
tv.clearAnimation();
tv.startAnimation(a1);
lhsv.addView(tv, k);
}
hsv.addView(lhsv);
ll.addView(hsv);
感謝
根據建議,我曾經嘗試這樣做它的工作原理,但所有的觀點都一起,我想要的是一個視圖中輸入然後延遲一下,然後另一個視圖輸入等..這是代碼。
final Handler handler = new Handler();
LinearLayout ll = (LinearLayout)findViewById(R.id.ll);
final HorizontalScrollView hsv = new HorizontalScrollView(TestViewActivity.this);
final LinearLayout lhsv = new LinearLayout(TestViewActivity.this);
final Animation a1 = new AlphaAnimation(0.00f, 1.00f);
a1.setDuration(350);
a1.setFillAfter(true);
for(int k =0; k < 5; k++){
new Handler().postDelayed(new Runnable() {
public void run() {
//write your code here...
final TextView tv = new TextView(TestViewActivity.this);
tv.setText("Text");
tv.setTextSize(42);
tv.setPadding(10, 0, 10, 0);
tv.setVisibility(View.INVISIBLE);
tv.clearAnimation();
tv.startAnimation(a1);
lhsv.addView(tv, temp);
temp++;
}
}, 2000);
}
hsv.addView(lhsv);
ll.addView(hsv);
溫度是靜態的INT這裏.. – Programmer 2012-02-14 07:28:59