if You are using PageViewer .This is better much of viewflipper
public class AwesomePagerClass extends PagerAdapter implements ViewPagerTabProvider{
@Override
public int getCount() {
return mparentId.length;
}
/**
* Create the page for the given position. The adapter is responsible
* for adding the view to the container given here, although it only
* must ensure this is done by the time it returns from
* {@link #finishUpdate()}.
*
* @param container The containing View in which the page will be shown.
* @param position The page position to be instantiated.
* @return Returns an Object representing the new page. This does not
* need to be a View, but can be some other container of the page.
*/
@Override
public Object instantiateItem(View collection, int position) {
Log.v("ViewPager", "instantiate :: called on position " + position);
parentId=mparentId[position];
productlist=new ProductListView(mconext, parentId);
((ViewPager) collection).addView(productlist,0);
return productlist;
}
/**
* Remove a page for the given position. The adapter is responsible
* for removing the view from its container, although it only must ensure
* this is done by the time it returns from {@link #finishUpdate()}.
*
* @param container The containing View from which the page will be removed.
* @param position The page position to be removed.
* @param object The same object that was returned by
* {@link #instantiateItem(View, int)}.
*/
@Override
public void destroyItem(View collection, int position, Object view) {
Log.v("ViewPager", "destroyItem :: called on position "+ position);
((ViewPager) collection).removeView((View) view);
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view==((View)object);
}
}
public class AwesomePagerClass extends PagerAdapter implements ViewPagerTabProvider{
@Override
public int getCount() {
return mparentId.length;
}
/**
* Create the page for the given position. The adapter is responsible
* for adding the view to the container given here, although it only
* must ensure this is done by the time it returns from
* {@link #finishUpdate()}.
*
* @param container The containing View in which the page will be shown.
* @param position The page position to be instantiated.
* @return Returns an Object representing the new page. This does not
* need to be a View, but can be some other container of the page.
*/
@Override
public Object instantiateItem(View collection, int position) {
Log.v("ViewPager", "instantiate :: called on position " + position);
parentId=mparentId[position];
productlist=new ProductListView(mconext, parentId);
((ViewPager) collection).addView(productlist,0);
return productlist;
}
/**
* Remove a page for the given position. The adapter is responsible
* for removing the view from its container, although it only must ensure
* this is done by the time it returns from {@link #finishUpdate()}.
*
* @param container The containing View from which the page will be removed.
* @param position The page position to be removed.
* @param object The same object that was returned by
* {@link #instantiateItem(View, int)}.
*/
@Override
public void destroyItem(View collection, int position, Object view) {
Log.v("ViewPager", "destroyItem :: called on position "+ position);
((ViewPager) collection).removeView((View) view);
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view==((View)object);
}
}
No comments:
Post a Comment