0
我试图将资源字符串名称附加到表达式,但无法继续。我的代码如下:错误发生在createFromResource
方法的参数R.array.+ precedingDigitsIdentifier
中。任何解决方法?android将字符串值名称连接到表达式
public void createPrecedingDigitsSpinner(String selectedCountry){
String selectedCntry =selectedCountry.toLowerCase();
/**confirm that value of this
* country exist in countries.xml**/
ArrayAdapter<CharSequence> adapter;
String precedingDigitsIdentifier = selectedCntry + "_preceding_digits";
try{
ArrayAdapter.createFromResource(getActivity(),*R.array.+ precedingDigitsIdentifier*,
android.R.layout.simple_spinner_item);
}catch (Resources.NotFoundException e){
CharSequence text = "the selected country contains no preceding digits data try another time";
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
}
你得到什么错误? – Paradox
在代码中,我看到* R.array而不是“R.array – Paradox