Mình có 1 vấn đề như sau: Mình lấy tất cả các image từ SDCard đưa vào 1 list (trong Activity1). Sau đó mình muốn chuyển cái list này qua Activity2 để xử lý :
Ở Activity1 :
Mã:
public List<Item> list;
private GridView gv;
....
int i = 0;
while (i < cursor.getCount()){
cursor.moveToNext();
String path = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA));
Bitmap img = BitmapFactory.decodeFile(path);
String name = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DISPLAY_NAME));
list.add(new Item(name,img));
i++;
}
...
gv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Toast.makeText(gripview_anh.this, "Anh " + position, Toast.LENGTH_SHORT).show();
//Tạo 1 đối tượng Bundle để gửi đi cùng Intent
Bundle sendBundle = new Bundle();
sendBundle.putInt("khoa", position);
//Tạo Intent để khởi chạy Activity2 và gắn sendBundble vào Intent
Intent i = new Intent(gripview_anh.this, view_image.class);
i.putExtras(sendBundle);
startActivity(i);
}
});
Ở Activity2:
Mã:
//Lấy về Bundle được gửi kèm Intent rồi lấy ra giá trị
Bundle receiveBundle = this.getIntent().getExtras();
int position = receiveBundle.getInt("khoa");
ImageView image = (ImageView)findViewById(R.id.imageview);
image.setImageResource(Giá_Trị_Cần_Hiển_Thị);
Nhưng phần màu đỏ ở Activity2 ("Giá_Trị_Cần_Hiển_Thị"). Làm sao để lấy giá trị trong list để hiển thị ra.
Thông qua phân tích dữ liệu Google từ 86 quốc gia, mới đây, một công ty tại Anh đã công bố bảng xếp hạng kích tấc "cậu nhỏ" của các nước trên thế giới. Kết quả, hầu hết các nước xếp ở nhóm đầu của...
"Chim" của chàng trai Việt thuộc...