简体   繁体   中英

How do i use getIntent().getSerializableExtra to retrieve data from the database

i passed data from one activity to another and found this way to retrieve my get methods from my Shop class.

now i do not know how to proceed to insert these data into the TextViews or ImageViews in my DetailsActivity.

how would i go about doing this?

this is my code so far:

public class DetailsActivity extends AppCompatActivity {

    private FirebaseFirestore firebaseFirestore;
    private RecyclerView FirestoreList;
    private FirestoreRecyclerAdapter adapter;
    TextView name_details;
    TextView address_details;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_details);


        Shop shopModel = (Shop) getIntent().getSerializableExtra("shopModel");



        name_details = findViewById(R.id.details_shopName);
        address_details = findViewById(R.id.detail_addressDetails);

    }
}

Simply use setText method with your TextView

name_details.setText(shopModel.yourNameValue());
address_details.setText(shopModel.yourAddressValue());

With ImageView is a little bit complicate if your image is from Internet. You need a image downloading library like Picasso or Glide

or if your image is from res/drawable , you just need to

imageView.setImageResource(shopModel.yourImageResId());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM