public class ImageViewActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
Integer[] ImgPreview = { R.drawable.mlview1, R.drawable.mlview2,
R.drawable.mlview3 };
super.onCreate(savedInstanceState);
setContentView(R.layout.image_prev);
Intent intent = null;
Bundle b = intent.getExtras();
int position = b.getInt("position");
// here, what to do?
if (position == 0) {
}
从上一个活动中,它取出参数“position”,根据“position”的值,它应该显示图像。例如:如果位置0,则显示图像“mlview1”,依此类推。
答案 0 :(得分:1)
写下这个..
ImageView imageView = (ImageView) findViewById(R.id.imageview); // Here R.id.imageview is id of ImageView fro your image_prev xml file.. change according it..
imageView.setImageResource(ImgPreview[position]);