Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
422 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 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...