I came across the same error message and solved it this way.
My code initially looked like:
private void displayQuantity(int quantity) { TextView quantityTextView = (TextView) findViewById(R.id.quantity_text_view); quantityTextView.setText("" + quantity); }
I got the error message "Do not concatenate the text displayed with setText. Use a resource string with placeholders." So
I added this to strings.xml
<string name="blank">%d</string>
What is my initial "+" for my number (quantity).
note: my quantity variable was previously defined and is what I wanted to add to the line. In java code I wrote.
private void displayQuantity(int quantity) { TextView quantityTextView = (TextView) findViewById(R.id.quantity_text_view); quantityTextView.setText(getString(R.string.blank, quantity)); }
and my mistake has disappeared. The behavior in the application did not change, and my quantity continued to be displayed as I wanted it, without a lint error.
user1580203 Jan 28 '16 at 5:46 2016-01-28 05:46
source share