E có listview có từng mục A B C trên main activity 1 bây giờ e muốn khi click vào A sẽ hiện nội dung của A bên main activity 2, B C cũng vậy. E phải làm như nào ạ, bác nào có video share e or chỉ e vs ạ, e tham khảo nhiều bài nhưng vẫn chưa làm được ạ. mn cứu e. em dùng csdl MySQL ạ
Truyền dữ liệu từ Main 1 sang Main 2 trong Android
em tìm hiểu về intent thì sẽ rõ. Tham khảo thêm:
ListVew.setOnItemLickListener(new OnItemLickListener(){
// chọn phần tử để truyền
ObjectSellected object =adapter.getItem(position);
// dùng intent truyền dữ liệu và mở Activty cần truyền sang
Intent intent=new Intent(MainAtivity.this,Main2Activty.class);
intent.putExtra(object,"objectSellected");
startActivty(intent);
}
// lấy dữ liệu truyền
Intent intent=getIntent();
ObjectSellected object=intent.getSerializableExtra("objectSellected");
1 Like