Android Sample Project Part - 3
In this section you will know more android sample project , and this part we will learn more about xml file.
In this part we will store variable name and values in String.xml file in android sample project .
To store variable and values in string.xml to ,go to android project
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">salary</string>
<string name="action_settings">Settings</string>
<string name="SalaryTax">Tax payment</string>
<string name="Salary">Salary</string>
<string name="CalculateTax">Calcualte</string>
<string name="NetSalary">balance</string>
<string name="Tax">Tax</string>
<string name="introductionTaz">1$ = 4000 Riels</string>
</resources>
You saw some variable and values stores in string.xml file and ti was used activity_main.xml
Example:1
android:text="@string/SalaryTax" ,also you can call to use it in MainActivity.java like this
Example:2
Toast.makeText(MainActivity.this, getString(R.string.SalaryTax, comp, guesses),
Toast.LENGTH_LONG).show();
EmoticonEmoticon