gourav sarswa
gourav sarswa

Reputation: 335

TextView is not showing proper text from string resources.

I have below string resources in my android studio project.

<string name="not_registered">Haven&#39;t registered yet?</string>

I set the string into TextView with following code:-

android:text="@string/not_registered"

It show proper text in xml preview window as expected:-

Haven't registered yet?

But when i run the project then it doesn't show the text after special char " ' ". It only show

Haven

I am not able to understand why it is not showing full string.

Upvotes: 0

Views: 987

Answers (6)

Saurabh Bhandari
Saurabh Bhandari

Reputation: 2458

As per Android Documentation. spacial character Single quote (')
cab be used any way of the following:

  • \'
  • Enclose the entire string in double quotes ("This'll work", for example)

In your case You can use as follows

<string name="not_registered">Haven\'t registered yet?</string>
<string name="not_registered">"Haven't registered yet?"</string>

both way will work.

Upvotes: 2

user8959091
user8959091

Reputation:

All of the below code look fine in preview:

<string name="not_registered">Haven&#39;t registered yet?</string>
<string name="not_registered">Haven&apos;t registered yet?</string>
<string name="not_registered">Haven\'t registered yet?</string>

but only the 3d works!!!

Upvotes: 1

Sasi Kumar
Sasi Kumar

Reputation: 13288

<string name="not_registered">Haven\'t registered yet?</string>

Upvotes: 1

InsaneCat
InsaneCat

Reputation: 2161

Try like this:

 <string name="not_registered">Haven\'t registered yet?</string>

it's working

Upvotes: 1

Nazmus Saadat
Nazmus Saadat

Reputation: 973

Use <string name="not_registered">Haven\'t registered yet?</string> instead of <string name="not_registered">Haven&#39;t registered yet?</string>

Upvotes: 3

Hitesh Kanjani
Hitesh Kanjani

Reputation: 200

First, change into your string resource.

<string name="not_registered">Haven\'t registered yet?</string>

And set the string into TextView with following code:-

android:text="@string/not_registered"

Upvotes: 4

Related Questions