我想知道我擁有包含狀態消息的string.xml資源文件。現在我想根據他們的ID來處理它們。我寫了下面的代碼,但它在Message = res.getString(Msgid);
和日誌Resource not found Exception
上失敗。如何在Android中使用Resource.getString(id)訪問資源文件中的特定字符串
任何人都可以幫助我嗎?
public void FileStatusMsg(int Msgid)
{
String Message = null;
Resources res = this.getResources();
Message = res.getString(Msgid);
//Display Status Messages..
AlertDialog.Builder builder = new AlertDialog.Builder(OfficeLinQ.this);
builder.setMessage(Message).setCancelable(false).setPositiveButton(
"OK", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
什麼是你MSGID?你如何獲得它? – 2011-06-02 07:58:34
你作爲Msgid傳遞了什麼? – Geobits 2011-06-02 07:58:58
Msgid的值來自哪裏?看起來它實際上並不是一個資源ID。 – fleetway76 2011-06-02 07:59:45