I have a simple animation attached to dynamic textview that i am creating but what i want is to add delay while adding them. Please guide me how to do that.
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);
Thanks
Based on suggestion i have tried this it works, but all view come all together, what i want is that one view enter then bit of delay then another view enter and so on...this is the code.
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);