Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
406 views
in Technique[技术] by (71.8m points)

Android Firebase Model Class

Here is my Model Class

public class Sell {


private String transactionID;
private int dollarPrice;
private boolean isInParts;
private String itemName;


public Sell() {
}


public Sell(String transactionID,
            int dollarPrice,
            boolean isInParts,
            String itemName) {

    this.transactionID = transactionID;
    this.dollarPrice = dollarPrice;
    this.isInParts = isInParts;
    this.itemName = itemName;
}


public String getTransactionID() {
    return transactionID;
}

public int getDollarPrice() {
    return dollarPrice;
}

public boolean isInParts() {
    return isInParts;
}

public String getItemName() {
    return itemName;
}



public void setTransactionID(String transactionID) {
    this.transactionID = transactionID;
}

public String getSellingString() {
    String string = "I want to Sell "+DOLLAR_SIGN+dollarPrice+ " "+itemName;

        if (isInParts) {
            string +=  " in Parts";
            // I want to sell $100 Goods in Parts
        }
    }
    return string;
  }
}

When i commit it to firebase with the following parameters

transactionId = "6475xxx-xxxxxxxxxxx" dollarPrice = 100 inParts = true itemName = "Goods"

i get the following in my firebase dashboard

{
 "dollarPrice" : 100,
 "inParts" : true,
 "itemName" : "Goods",
 "transactionID" : "6475xxx-xxxxxxxxxxx"
}

but in my recycler view's view holder i have a text view which i set the following text

textview.setText(sell.getSellingString());

my textView always displays

I want to sell $100 Goods

Instead of

I want to sell $100 Goods in Parts

Thereby neglecting the boolean value i specified.

How can i get Around this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...