How can I get text from the strings.xml file into my .setmessage?
show = new AlertDialog.Builder(mContext).setTitle("moria")
.setMessage("R.string.erroroik")
.setPositiveButton("OK", null).show();
android:text="@string/hello" /> String string = getString (R. string. hello); You can use either getString(int) or getText(int) to retrieve a string.
String. xml file contains all the strings which will be used frequently in Android project. String. xml file present in the values folder which is sub folder of res folder in project structure.In Android Studio, we have many Views such as TextView,Button,EditText,CheckBox,RadioButton etc.
String Element – length – 1). Using index: Returns the character at specified index. Using get function: Returns the character at specified index passed as argument to get function. Iterating over the String: Using loops to access the characters in the String.
You can access it through context, depending where exactly this DialogBuilder is, it can be
context.getString(R.string.erroroik);
or
this.getString(R.string.erroroik);
Take a look at String Resources for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With