0
我已經創建了一個應用程序,該應用程序將imagelider與使用尋呼機適配器的視圖尋呼機一起使用。我創建了大約5個使用不同圖像和不同圖像計數的imagelider活動。但是在手機上運行應用程序時,它顯示的圖像集和相同的計數。請看看使用imagelider的3個活動。我無法解決問題。 月1日活動圖像Swipeview在所有活動中都顯示相同的圖像
public class customSwipe3 extends PagerAdapter {
private int[] imageResources = {R.drawable.vcard_a,R.drawable.vcard_b,R.drawable.vcard_c,R.drawable.vcard_d,R.drawable.vcard_e};
private Context ctxb;
private LayoutInflater layoutInflaterb;
public customSwipe3(Context e) {
ctxb=e;
}
@Override
public int getCount() {
return imageResources.length;
}
@Override
public Object instantiateItem(ViewGroup containerb,int positionb){
layoutInflaterb = (LayoutInflater) ctxb.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView3 =layoutInflaterb.inflate(R.layout.activity_custom_swipe3,containerb,false);
ImageView imageView3 = (ImageView)itemView3.findViewById(R.id.swip_image_view3);
TextView textView3 =(TextView)itemView3.findViewById(R.id.imagecount3);
imageView3.setImageResource(imageResources[positionb]);
textView3.setText("Design No :"+positionb);
containerb.addView(itemView3);
return itemView3;
}
@Override
public void destroyItem(ViewGroup containerb ,int positionb ,Object objectb){
containerb.removeView((LinearLayout) objectb);
}
@Override
public boolean isViewFromObject(View viewb,Object objectb) {
return (viewb==objectb);
}
你設置適配器代碼2
public class customSwipe1 extends PagerAdapter {
private int[] imageResourcea = {R.drawable.brochure_a,R.drawable.brochure_b,R.drawable.brochure_c,R.drawable.brochure_d,R.drawable.brochure_e,R.drawable.brochure_f};
private Context ctxa;
private LayoutInflater layoutInflatera;
public customSwipe1(Context d) {
ctxa=d;
}
@Override
public int getCount() {
return imageResourcea.length;
}
@Override
public Object instantiateItem(ViewGroup containera,int positiona){
layoutInflatera = (LayoutInflater) ctxa.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemViewa =layoutInflatera.inflate(R.layout.activity_custom_swipe1,containera,false);
ImageView imageViewa = (ImageView)itemViewa.findViewById(R.id.swip_image_view1);
TextView textViewa =(TextView)itemViewa.findViewById(R.id.imagecount1);
imageViewa.setImageResource(imageResourcea[positiona]);
textViewa.setText("Brochure No :"+positiona);
containera.addView(itemViewa);
return itemViewa;
}
@Override
public void destroyItem(ViewGroup containera ,int positiona ,Object objecta){
containera.removeView((LinearLayout) objecta);
}
@Override
public boolean isViewFromObject(View viewa,Object objecta) {
return (viewa==objecta);
}
代碼3
public class customSwipe4 extends PagerAdapter {
private int[] imageResources = {R.drawable.letterheads_a,R.drawable.letterhead_b};
private Context ctxc;
private LayoutInflater layoutInflaterc;
public customSwipe4(Context f) {
ctxc =f;
}
@Override
public int getCount() {
return imageResources.length;
}
@Override
public Object instantiateItem(ViewGroup containerlh, int positionlh) {
layoutInflaterc = (LayoutInflater) ctxc.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView4 = layoutInflaterc.inflate(R.layout.activity_custom_swipe4, containerlh, false);
ImageView imageView4 = (ImageView) itemView4.findViewById(R.id.swip_image_view4);
TextView textView4 = (TextView) itemView4.findViewById(R.id.imagecount4);
imageView4.setImageResource(imageResources[positionlh]);
textView4.setText("Design No :" + positionlh);
containerlh.addView(itemView4);
return itemView4;
}
@Override
public void destroyItem(ViewGroup containerlh, int positionlh, Object objectlh) {
containerlh.removeView((LinearLayout) objectlh);
}
@Override
public boolean isViewFromObject(View viewlh, Object objectlh) {
return (viewlh == objectlh);
}