Call button name text through strings.xml file in android

Add button name, TextView text, EditText hint via strings.xml file.

When android developer creates multiple buttons used in multiple activities then its not easy to remember all those names and check there names each and every time you have to open activity_main.xml file and check button name but after defining button name text into strings.xml file you can straight check via opening it. So here is the complete step by step tutorial for Call button name text through strings.xml file in android.

How to Call button name text through strings.xml file in android.

The text name through strings.xml file is called via s attribute. In this attribute @string is represents here string file path and after it button_name_text represents button name text defined in strings.xml file. But first you need to open strings.xml file and define button name text then you can set it any button or TextView tag.

1. So first open string.xml file.

locate strings xml file in eclipse

2. Now define text via string tag like i do in below example.

<string name="button_name">This text is coming from Strings.xml file</string>

At above line name =” button_name” is the name so you can call that name in button or textview tag.

 <Button
 android:id="@+id/button1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_centerHorizontal="true"
 android:layout_centerVertical="true"
 android:text="@string/button_name" />

After completing this procedure automatically button name changed as define text in string text.

Call button name text through strings.xml file in android

Leave a Reply

Your email address will not be published. Required fields are marked *