2011-08-03 60 views
0

我在xml文件中有一个数组,它试图访问,但是它返回null。在android中获取数组返回null

XML:

<array name="phone"> 
    <item>17809272426</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); 

感谢= d

回答

2

只要仔细检查您的syntax那里,而不是array使用string-array

+0

非常感谢^^ – gammaraptor

相关问题