When working with Android Application we might have faced this error after placing a button or other controls on the Form indicating that Hardcoded string should use @string resource.
Here we will learn how to resolve this issue when working with our Android Application.
Structure of our Project
Here we, need to declare string variable for Button with the value that should be displayed in the Label of Button control.
This can be done by navigating to values Menu in the Structure displayed.
Double-click on the string.xml the Android Resource Elements is displayed,
Now, it’s time to declare a string variable for the Button control. Click Add button a screen pop-ups showing the creation of new element, select string and click OK.
Next, we declare the Name and value of the Element to be defined as shown,
Replace the Button Text property with the element name with the @string variable we have defined as like this,
And then, the XML File looks something like this,’
Now, once we switch over to Graphical Layout, the screen is as shown below.
Hope this might be useful a little.