使用字符串資源我試圖從IntentService獲得字符串資源值,如下所示:錯誤在IntentService
String errorTitle = getResources().getString(R.string.no_Internet_connection_error_title);
但它顯示了一個錯誤no_Internet_connection_error_title cannot be resolved or is not a field
。
當我鍵入R.string.
時,eclipse顯示了一個android定義的字符串列表,這個字符串不是由我定義的。
我在活動中使用字符串資源,但無法在IntentService中使用。
導入R類別'進口com.example.androidtest .R;' –
請刪除R.String騙取並導入您的R.class文件 – abhi
可能是一個錯誤的導入。您可以使用前綴(包名稱)以確保您使用的是正確的包。如果你使用它,它會起作用嗎? 'getResources()。getString(yourproject.package.name.R.string.no_Internet_connection_error_title)' – Zhar