Find us on facebook

May 27, 2015

strings.xml

In Eclipse the strings.xml file is used to declare strings instead of hard-coding them into other project files.

Place your strings in strings.xml file like shown in this example, and reference those strings in your other project files.

FirstApp/res/layout/activity_main.xml

 <EditText
        android:id="@+id/editText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editText1"
        android:layout_below="@+id/editText1"
        android:layout_marginTop="67dp"
        android:ems="10"
        android:hint="@string/Password"
        android:inputType="textPassword" />

FirstApp/res/values/strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="Password">Password</string>
</resources>

No comments:

Post a Comment