How can i get image from ListView page to Details View page? I just can get the textview and cannot get the imageview. Is it my coding is wrong? How can i fixed it? Please help me thanks.
this is my ListView
public static final String IMAGE_NAME= "com.example.weichuan.batupahatcarworkshopsfinder.workshopsId";
private DatabaseReference mDatabaseRef;
private List<ImageUpload> imgList;
private ListView lv;
private ImageListAdapter adapter;
private ProgressDialog progressDialog;
private FirebaseAuth firebaseAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_list);
imgList = new ArrayList<>();
lv= (ListView) findViewById(R.id.listViewImage);
progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Please wait loading list image...");
progressDialog.show();
firebaseAuth = FirebaseAuth.getInstance();
mDatabaseRef = FirebaseDatabase.getInstance().getReference(WorkshopsInfoActivity.FB_DATABASE_PATH);
mDatabaseRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
progressDialog.dismiss();
for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
ImageUpload img = snapshot.getValue(ImageUpload.class);
imgList.add(img);
}
adapter = new ImageListAdapter(ImageListActivity.this, R.layout.image_item, imgList);
lv.setAdapter(adapter);
}
@Override
public void onCancelled(DatabaseError databaseError) {
progressDialog.dismiss();
}
});
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
ImageUpload imgList = (ImageUpload) adapterView.getAdapter().getItem(position);
Intent intent = new Intent(ImageListActivity.this, DetailsOfWorkshops.class);
String name = imgList.getName();
String address = imgList.getAddress();
String contact = imgList.getContact();
String category = imgList.getCategory();
String URL = imgList.getUrl();
intent.putExtra("Name", name);
intent.putExtra("Address", address);
intent.putExtra("Contact", contact);
intent.putExtra("Category", category);
intent.putExtra("URL", URL);
startActivity(intent);
}
});
}}
this is my Details View
DatabaseReference mDatabaseRef;
private TextView textViewAddress;
private TextView textViewContact;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details_of_workshops);
mDatabaseRef = FirebaseDatabase.getInstance().getReference(WorkshopsInfoActivity.FB_DATABASE_PATH);
mDatabaseRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Bundle img = getIntent().getExtras();
final String name = img.getString("Name");
final String address = img.getString("Address");
final String contact = img.getString("Contact");
final String category = img.getString("Category");
String URL = img.getString("URL");
final TextView textViewName = (TextView) findViewById(R.id.ImageName);
final TextView textViewAddress = (TextView) findViewById(R.id.ImageAddress);
final TextView textViewContact = (TextView) findViewById(R.id.ImageContact);
final TextView textViewCategory = (TextView) findViewById(R.id.ImageCategory);
final ImageView textViewImage = (ImageView) findViewById(R.id.ImageView);
textViewName.setText(name);
textViewAddress.setText(address);
textViewContact.setText(contact);
textViewCategory.setText(category);
textViewImage.setText(URL);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}}