Finding all identifiers containing part of the token

I know I can get a string from resources using

Resources.GetIdentifier(token, "string", ctx.ApplicationContext.PackageName)

(sorry, this is in C#, it’s part of a Xamarin.Android project).

I know that if my elements are called foo_1, foo_2, foo_3, then I can iterate and grab the strings using something like

var myList = new List<string>();
for(var i = 0; i < 4; ++i)
{
     var id = AppContent.GetIdentifier(token + i.ToString(), "string", "package_name");
     if (id != 0)
        myList.Add(AppContext.GetString(id));
}

My issue is say my token names all begin with “posn.” (the can denote the position of anything, so you can have “posn.left_arm” and “posn.brokenose”). I want to be able to add to the list of posn elements, so can’t really store a list of the parts after the period. I can’t use a string-array for this either (specific reason means I can’t do this).

Is there a way that I can use something akin to “posn.*” in the getidentifer call to return the ids?


Source: android

Leave a Reply