As my title says, how do I include a resource string in XML format that I can access by its id? This id is auto generated in dot42 but I can't find any teachings in Google.
Asked
Active
Viewed 484 times
2 Answers
1
Create a new file strings.xml with this content:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="firstName">MisterFive</string>
</resources>
Include it in your project and set the Build Action property to 'ValuesResource'.
If you open R.cs (inside properties folder), you will see that the following code is generated:
//------------------------------------------------------------------------------
// This file is automatically generated by dot42
//------------------------------------------------------------------------------
namespace dot42Application2
{
using System;
public sealed class R
{
public sealed class Strings
{
public const int firstName = 0x7f040000;
}
}
}
You can access your string resource from C# like this:
string firstName = GetString(R.Strings.firstName);

Frank Rem
- 3,632
- 2
- 25
- 37
-
Thanks for this answer! I made an answer too but this one is different(somewhat manually) so I think it could help someone too :) – mr5 Apr 22 '14 at 09:02
0
NM! Just figure it out again.
For anyone who came into this problem, just go to:
Solution Explorer > Project(Right Click) > Add > New Item > Dot42 > Android > String table resource > Build (Press F7) > Done!

mr5
- 3,438
- 3
- 40
- 57