Android Studio" R.array"错误:(36,44)错误:找不到符号变量数组

时间:2017-07-07 02:58:18

标签: android arrays

错误突出显示文本"数组"红色。我该如何解决?

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);

1 个答案:

答案 0 :(得分:0)

您在res / values文件夹中的arrays.xml文件中使用TypedArray,如下所示:

<?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>