这是我的网格视图,它是通过使用intent ...`
来查看寻呼机类的传递位置public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
int pos = 0;
LayoutInflater inflater = ((Activity) m1Context)
.getLayoutInflater();
View customRow1 = inflater.inflate(R.layout.gview, null);
ImageView image = (ImageView) customRow1
.findViewById(R.id.imageforgrid);
switch (gotbread) {
case 0:
image.setImageResource(images2[pos]);
break;
case 1:
image.setImageResource(images1[position]);
break;
}
image.setAdjustViewBounds(true);
image.setScaleX((float) 0.5);
image.setScaleY((float) 0.5);
image.setOnClickListener(new OnImageClickListener(position));
return customRow1;
}
}
class OnImageClickListener implements OnClickListener {
int _postion;
// constructor
public OnImageClickListener(int position) {
this._postion = position;
}
@Override
public void onClick(View v) {
// on selecting grid view image
// launch full screen activity
Bundle basket=new Bundle();
basket.putInt("position",_postion);
Intent i = new Intent(Customgrid.this,
FullScreenImageActivity.class);
i.putExtras(basket);
startActivity(i);
}
}
}
`
这里是用于在swip视图中显示图像的视图寻呼机...但它不是在全屏视图中显示图像..没有显示任何错误,但它只是黑屏而没有任何图像。
public class FullScreenImageActivity extends Activity {
int gotbiscuit;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.fullscreen_view);
ViewPager viewpager = (ViewPager) findViewById(R.id.pager);
Intent i = getIntent();
int gotbiscuit = i.getExtras().getInt("position");
System.out.print(gotbiscuit);
Fullscreenimage adapter = new Fullscreenimage(
FullScreenImageActivity.this);
viewpager.setAdapter(adapter);
// displaying selected image first
viewpager.setCurrentItem(gotbiscuit);
}
public class Fullscreenimage extends PagerAdapter {
public Integer[] images1 = { R.drawable.s_1, R.drawable.s_2, R.drawable.s_3 };
public Context mContext;
public Fullscreenimage(Context context) {
super();
this.mContext = context;
// TODO Auto-generated constructor stub
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return images1.length;
}
@Override
public boolean isViewFromObject(View arg0, Object arg1) {
// TODO Auto-generated method stub
return false;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
// TODO Auto-generated method stub
super.destroyItem(container, position, object);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
// TODO Auto-generated method stub
LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
View viewlayout = inflater.inflate(R.layout.layout_fullscreen_view,
container, false);
ImageView imageview = (ImageView) viewlayout
.findViewById(R.id.imgDisplay);
imageview.setImageResource(images1[gotbiscuit]);
((ViewPager) container).addView(viewlayout, 0);
return viewlayout;
}
}
}