class MyPagerAdaptor extends PagerAdapter
{
LayoutInflater inflater;
public MyPagerAdaptor(){
inflater = getLayoutInflater();
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return mIdList.size();
}
@Override
public Object instantiateItem(ViewGroup viewGroup, int position) {
// TODO Auto-generated method stub
/*if(flag)
{
mPosToShare = position;
System.out.println("mPosToShare......: "+mPosToShare);
flag = false;
}*/
System.out.println("instantiateView............."+position);
View imageLayout = inflater.inflate(R.layout.item_pager_image, viewGroup, false);
ImageViewTouch imageView = (ImageViewTouch) imageLayout.findViewById(R.id.image);
try
{
InputStream is = mExpansionFile.getInputStream("worlatlaspronewmaps/"+title[1]+mIdList.get(position)+".jpg");
//InputStream is1 = mExpansionFile.getInputStream("worlatlaspronewmaps/"+title[1]+mIdList.get(position-1)+".jpg");
if(is == null)
{
is = mExpansionFile.getInputStream("worlatlaspronewmaps/"+title[1]+mIdList.get(position)+".JPG");
}
bitmap = BitmapFactory.decodeStream(is,null,bfOptions);
System.out.println(bitmap);
imageView.zoomTo(0.5f,50);
imageView.setImageBitmap(bitmap);
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
viewGroup.addView(imageLayout,0);
return imageLayout;
}
@Override
public boolean isViewFromObject(View view, Object object) {
// TODO Auto-generated method stub
return (view==object);
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
((ViewPager) container).removeView((View) object);
}
}
MyPagerAdaptor 类正在用位图填充 viewpager,因为寻呼机的每个视图都包含一个 imageview,但是当我获得位图的引用时,它给出了不可见的右位图或左位图的引用。我需要可见的位图参考。