大家好,
我在查看寻呼机方面遇到麻烦,因为当我滑动视图时,它会冻结视图寻呼机一段时间,然后在添加新视图ID时滑动。是否有任何解决方案可以阻止视图暂停?我有一个想法,但不知道如何实现我们可以立即创建所有的视图。然后添加到查看寻呼机。
我试过这段代码请查看我在此代码中要修改的内容
import java.util.Vector;
import android.app.Activity;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
public class CustomPagerAdapter extends PagerAdapter {
private Context mContext;
private Vector<View> pages;
private Activity actl;
public CustomPagerAdapter(Context context, Vector<View> pages,Activity act) {
this.mContext=context;
this.pages=pages;
actl=act;
}
@Override
public Object instantiateItem(final ViewGroup container, int position) {
final View page = pages.get(position);
//container.addView(page);
// IN this line we are adding view every time and it is halting the viewpager for few sec
((ViewPager) container).addView(page,0);
return page;
}
@Override
public int getCount() {
return pages.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view.equals(object);
}
@Override
public void destroyItem(ViewGroup pager, int position, Object view) {
// container.removeView((View) object);
((ViewPager)pager).removeView((View)view);
}
}