0

I try to use string.xml in java file by using getString but it gives me an error in add, price, and addc variables because it is a different datatype. However, I see the same code on the internet and its work!

  private String createOrderSummary(int price, boolean add, boolean addc, String n) {
    String message = getString(R.string.name , n) ;
    message += "\n" + getString(R.string.quantityorder, quantity);
    message +=  "\n" + getString(R.string.total, price);
    message += "\n" + getString(R.string.cream, add);
    message += "\n" + getString(R.string.choclate, addc);
    message += "\n" + getString(R.string.Thank_you);
    return message;
}

2 Answers2

0

Didn't get your question clearly, but probably what you need is Integer.toString(your_integer_variable) method

Similary for other datatypes there are methods like Character.toString() or Float.ToString()

Hope this helps :)

0

for integers you can use for example

getString(R.string.quantityorder, quantity + "" )

and for all solution you can use

Float.toString()
Integer.toString()
DolDurma
  • 15,753
  • 51
  • 198
  • 377