开发者

Getting array in android is returning null

开发者 https://www.devze.com 2023-03-26 05:40 出处:网络
I have an array in an xml file that i\'m trying to access, however it is returning null. XML: <array name=\"phone\">

I have an array in an xml file that i'm trying to access, however it is returning null.

XML:

<array name="phone">
    <item>178092724开发者_Python百科26</item>
    <item>17809272426</item>
    //etc...
</array>

Java:

String[] phonenumber;
phonenumber = getResources().getStringArray(R.array.phone);
Toast callContact = Toast.makeText(getApplicationContext(), phonenumber[position], Toast.LENGTH_SHORT);
callContact.show(); //blank but it shouldn't be...
Intent contactdial = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + (phonenumber[position])));
startActivity(contactdial);

Thanks =D


Just double check your syntax there, instead of array use string-array.

0

精彩评论

暂无评论...
验证码 换一张
取 消