-1

Error highlights the text "array" red. How do I fix it?

public class Signup extends Activity {

    AutoCompleteTextView y;
    String[] z;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.signup);

        y = (AutoCompleteTextView) findViewById(R.id.cntry);
        z = getResources().getStringArray(R.array.country);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, z);
Kohei TAMURA
  • 4,970
  • 7
  • 25
  • 49
  • You have answer here [create Array](https://stackoverflow.com/questions/10774668/resource-arrays) – Bala Raja Jul 07 '17 at 03:07
  • `R.x.foo` is "automatically" generated by the resource file/manifest. If the compiler is throwing an error about `x.foo`, then the chances are `x.foo` does not correspond to a defined resource. – user2864740 Jul 07 '17 at 03:18

1 Answers1

0

You use a TypedArray in arrays.xml file within your res/values folder that looks like this,

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="country">
        <item>@drawable/pakistan</item>
        <item>@drawable/india</item>
        <item>@drawable/USA</item>
    </string-array>
</resources>
Adnan Maqbool
  • 452
  • 3
  • 10