While I am working with help of tutorial I found this in textview android:text-"@string/hello" it shows some error.
Then I went through graphical view and right click the component and enter the text. Then that error removes and notifies me that
**Hardcoded string hello should use String resources**
In android, "@string/" refer to the string.xml in Project>res>values> location in your package explorer.
String.xml contains a xml file which refer to a string with an id. Eg:
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World</string> <string name="app_name">My app</string> </resources>
Here name="hello" is the id & "Hello World" is its value. When @string/hello is used, the value will be shown.
Similar is the case with "@drawable/". It will refer to the images used. and many more.
You can set text in text view pragmatically: Eg:
TextView tv = (TextView)findViewById(R.id.text1); //text1 is the id u provide in xml file tv.setText("Hello World");
I hope it helped you.