Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get data from the strings.xml

Tags:

android

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();
like image 287
menu_on_top Avatar asked Mar 02 '11 16:03

menu_on_top


People also ask

How do you get string resources?

android:text="@string/hello" /> String string = getString (R. string. hello); You can use either getString(int) or getText(int) to retrieve a string.

What is strings xml?

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.

How do you access string in Kotlin?

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.


1 Answers

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.

like image 117
David Kuridža Avatar answered Oct 02 '22 12:10

David Kuridža