Stephen
Stephen

Reputation: 10059

How to display a contact number in android

I need to display a Contact Number in android.So far I done it in textView.But I couldn't able to get the result.

For Eg: If Contact Number is 86081***20.

I need to display this number in android.xml.Anybody can help me with these.Thank you.

contact.xml

<TextView android:id="@+id/textView9"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@string/number1" /> 

strings.xml:

<string name="number1">86081***20 </string>

I done it like these.

Finally output shows like @String/number1

Upvotes: 0

Views: 198

Answers (1)

MysticMagicϡ
MysticMagicϡ

Reputation: 28823

android:text="@string/number1"

will only work when you have any string resource with that name in your values/strings.xml file.

<string name="number1">86081***20</string>

But mostly you are getting it dynamically, so you will need to set the textview text in java like this in onCreate:

String someContactNum = "86081***20";
TextView txtView = (TextView) findViewById(R.id.contact_text);
txtView.setText(someContactNum);

Hope it helps.

Upvotes: 1

Related Questions