0

I have tried

String name = mContext.getString(R.string.product_and_quantity, banner.getProduct_name().trim(), banner.getProduct_quantity());

and in String.xml file

 <string name="product_and_quantity">%1$s x(%2$d)</string>

but still I am not getting proper view in some items as shown in image.

I tried this too

 String name=banner.getProduct_name().trim()+"x("+ banner.getProduct_quantity()+")";
       SpannableStringBuilder spannableStringBuilder=new SpannableStringBuilder();
       spannableStringBuilder.append(banner.getProduct_name().trim());
       spannableStringBuilder.append(" X(");

       spannableStringBuilder.append(Integer.toString(banner.getProduct_quantity()));
       spannableStringBuilder.append(mContext.getString(R.string.closing_bracket));

and string.xml file has

 <string name="closing_bracket">)</string>
but still i am getting the same error. 
I have invested 3-4 hours on stackoverflow about this error but no solution. Please help.

enter image description here

Durgesh Kumar
  • 935
  • 10
  • 17

1 Answers1

1

It could be that the text is too long and breaks into 3 lines and only the first two are shown. Like this:

Tandori
Sauce Pasta
(1)

And the textview is limited in height and only shows the first two lines.

EDIT

Based on the provided layout xml and discussion in comments, the solution was, to change the textview's height to match_parent.

Ridcully
  • 23,362
  • 7
  • 71
  • 86
  • when i hard code it . it shows properly. I have not added any line breaks. in logcat it is shown as `2020-09-02 10:14:22.075 16135-16135/com.bunny.burgersmore I/ListItemsAdapterAdmin: onBindViewHolder: Tandoori Sauce Pasta X(1)` – Durgesh Kumar Sep 02 '20 at 04:30
  • `` this is the textview code – Durgesh Kumar Sep 02 '20 at 04:32
  • 1
    If its showing correctly in Logcat, then its definitely that the TextView is not high enough. Change layout_height to 200dp or something and you'll see. – Ridcully Sep 02 '20 at 13:30
  • yes it worked when I did match_parent. Thanks for support. Kindly edit the answer so I can upvote it – Durgesh Kumar Sep 02 '20 at 14:44