我在 ListView 项目中有一个 ViewPager。在 ListView 滚动上,我想获取在 ViewPager 中选择的上一页。
我试图将位置设置为
vPager.setTag(position)
但没有办法检索我的上一页`
这是我的 ListView 的 getView()
public View getView(int position, View view, ViewGroup vGroup) {
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
vRow=view;
final ContentHolder holder;
if(view==null){
holder=new ContentHolder();
vRow=inflater.inflate(R.layout.activity_swipe_view_pager, null);
holder.vPager=(ViewPager) vRow.findViewById(R.id.ui_pager);
holder.radiogrp=(RadioGroup) vRow.findViewById(R.id.ui_radiogroup);
int pageCount=integer.length;
addRadio=new AddRadioViewSwipe(context, pageCount);
addRadio.addRadio(holder.radiogrp);
try{
holder.radiogrp.getChildAt(0).setAlpha(1.0f);
}
catch(Exception e){
Log.d("loop", "error"+e);
}
vRow.setTag(holder);
}
else{
holder=(ContentHolder) vRow.getTag();
}
ViewPagerAdapter pagerAdpt=new ViewPagerAdapter(context, integer,R.layout.activity_viewpager_model);
holder.vPager.setAdapter(pagerAdpt);
holder.vPager.setOffscreenPageLimit(3);
holder.vPager.setTag(position);
holder.vPager.setPageMargin(-150);
holder.vPager.setOnPageChangeListener(new OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
Log.d("pos", ""+position);
if(holder.vPager.isShown()){
}
for(int i=0;i<integer.length;i++){
holder.radiogrp.getChildAt(integer.length-(i+1)).setAlpha(0.5f);
}
holder.radiogrp.getChildAt(position).setAlpha(1.0f);
Log.d("pos", ""+position+"");
}
@Override
public void onPageScrolled(int position, float arg1, int arg2) {
Log.d("t1", ""+position);
}
@Override
public void onPageScrollStateChanged(int arg0) {
Log.d("t1...", ""+arg0);
}
});
return vRow;
}