16

R.string.Converasation contains Conversation Here is the code

tv.setText(R.string.Converasation+"HELLo");

textview view is taking int value of R.string.Converasation and string value of HELLo and finally displays 2131034187Hello but i want ConverasationHello

how to resolve this..

7 Answers 7

31

Try

tv.setText(getString(R.string.Converasation) + "HELLo");

Marc.

1
  • 3
    is my answer different from your? Commented Aug 4, 2011 at 9:21
20

It should be like:

tv.setText(getString(R.string.Converasation)+" Hello ");

FYI, You can use either getString(int) or getText(int) to retrieve a string.

0
2

@Mudassir everything works great. for me it's:

  display.setText(getText(R.string.counting_result) + " "+ counter);
1

Try following code:

  Resources res = context.getResources();
  float floatConverasation = 1.1f;
  String strfloatConverasation = "HELLO";
  tv.setText(String.format(Locale.ENGLISH,"%s %f %s",
    res.getString(R.string.conversation), floatConverasation, strfloatConverasation));
0

Try same

 tv.setText(getString(R.string.Converasation)+" Hello ");
0

You can do this as follows:

tv.setText(getText(R.string.Conversation)+" Hello");

Hope this will work.

0

It can be achieved by passing the string inside the resource i.e. getResources().getString(R.string.yourStringName)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.