Hi I am new to android and I am doing one simple application. My application contain one simple activity in witch it contains view pager. my view pager having no of screens 3. SO my view pager working fine. my first and second screen contains one button when i click on that button it will goes to third screen setCurrentItem(2);.
now what i want is when i go third screen it will render one view and few sec only like after completely rendering that view do some animation like flip animation.
what happen in reality when i click on buttons it directly go to that screen but not rendering that default view. it directly starts animation…
My code looks like
public class HelpActivity extends Activity {
private final int NUM_SCREENS = 3;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.help);
mInflater = LayoutInflater.from(this);
vp = (ViewPager) findViewById(R.id.pager);
PagerAdapter pagerAdapter = new MyPagerAdapter();
vp.setAdapter(pagerAdapter);
}
private OnClickListener signin = new OnClickListener() {
@Override
public void onClick(View arg0) {
vp.setCurrentItem(2);
// ******* do some animation on view 3 in pager views ....
}
};
private class MyPagerAdapter extends PagerAdapter {
@Override
public int getCount() {
return NUM_SCREENS;
}
@Override
public Object instantiateItem(View collection, int position) {
View view = null;
Typeface tf = Typeface.createFromAsset(getAssets(),
"fonts/sf_cartoonist_hand_bold.ttf");
if (position == 0) {
// display view1
// on button click call sign in
} else if (position == 1) {
//display view 2
//on button click call sign in
} else if (position == 2) {
//display view 3
}
((ViewPager) collection).addView(view, 0);
return view;
}
}
}
what i need after clicking on button it skips to view3 display for few sec and after that do animation… how to do that?
need help…..
thank you …..
Using
Runnableyou can hold your animation until your view is not load it properly, you have to measure that in how much seconds your view get load, so you can pass delay as per your view get load time, something like below:It start your animation after
2000 MilliSec