2012-05-17 69 views
0
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」,等等。在接受的位置的基礎上,如何顯示圖像?

回答

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]); 
+0

謝謝!成功了! – Shiven