-1

I'm trying to get a string from strings.xml into my Java file:

This is my Java code:

public class LGDial extends ActionBarActivity{
public static final String[] titles = new String[] { "Strawberry",
        "Banana", "Orange", "Mixed" };

Can someone please tell me how to define the text in strings.xml then get it.

Thank you in advance,

Badee
  • 33
  • 6
  • You should have searched here first http://developer.android.com/guide/topics/resources/string-resource.html – gnuanu Jul 23 '14 at 03:58

1 Answers1

0

If you want to use Strings in xml, you need to set like this first in your strings.xml of res/values.

<string name="app_name">Your App</string>

then you can use the string you want like below.

getString(R.string.app_name);

I hope it will help for you.

kimkevin
  • 2,202
  • 1
  • 26
  • 48