Reputation: 875
Here is my class where I am querying Firestore (using the Firebase-UI for Cloud Firestore) and binding the data:
protected void onBindViewHolder(@NonNull MenuHolder holder, int position, @NonNull MenuItems model) {
holder.textViewName.setText(model.getName());
holder.textViewDescription.setText(model.getDescription());
This works if I am getting and setting values for a TextView
. But if I just want to get the data and assign it to a string or parse it to an int, how would I do that?
Upvotes: 0
Views: 80
Reputation: 138969
According to your question and further comments, please see the code below:
protected void onBindViewHolder(@NonNull MenuHolder holder, int position, @NonNull MenuItems model) {
String name = model.getName();
holder.textViewName.setText(name);
String description = model.getDescription();
holder.textViewDescription.setText(description);
int taxAmount = model.getTaxAmount();
//Do what you need to do with it
}
See what I have done? Before setting the text to the actual text views, I have stored each value that is coming from a getters into a variable. I have done the same thing in case of the strings as well in the case of the integer. Obviously, I assumed that your taxAmount
is of type int
. If you want to diplay later in your project this property as well, please use the following line of code:
holder.textViewTaxAmount.setText(String.valueOf(taxAmount));
Upvotes: 1