同时,我将所有值传递给了一个意图,而所有传递给意图的值都传递给了另一个活动。但是如何在活动中通过回收站来获取我选择的数据?
这是我的适配器
@Override
public void onBindViewHolder(final ViewHolder viewHolder, final int position) {
final Pet pet = mPet.get(position);
viewHolder.petname.setText(mPet.get(position).getPetname());
Glide.with(mContext)
.load(pet.getPetimageurl())
.placeholder(R.drawable.placeholder)
.fitCenter()
.into(viewHolder.petimage);
// if (!mPet.get(position).)
viewHolder.pet_cardview_id.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
row_index = position;
notifyDataSetChanged();
String selected_my_pet = mPet.get(position).getPetid();
Log.d(TAG, "@@@@@@@@@@@@@@@"+selected_my_pet);
}
});
我可以从适配器中获取数据Petid() 但是如何在Acitivity中接收该数据?
这是我的活动
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot childSnapshot : dataSnapshot.getChildren())
{
String key = childSnapshot.getKey();
Pet pet = childSnapshot.getValue(Pet.class);
pet.getPetname();
pet.getPetimageurl();
lsPet.add(pet);
}
LinearLayoutManager layoutManager = new LinearLayoutManager(PetHospitalPetConditionActivity.this, LinearLayoutManager.HORIZONTAL, false);
RecyclerView recyclerview_dogs = findViewById(R.id.recyclerview_dogs);
recyclerview_dogs.setLayoutManager(layoutManager);
PetHospitalizationSelectAdapter petHospitalizationSelectAdapter = new PetHospitalizationSelectAdapter(PetHospitalPetConditionActivity.this, lsPet);
recyclerview_dogs.setAdapter(petHospitalizationSelectAdapter);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
我想一次将回收器中的选定数据和该活动中的复选框数据全部传输到另一个活动。如何从回收商中将选定数据的值检索到活动中?