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