Glenn Rodriguez
Glenn Rodriguez

Reputation: 71

Android/Xamarin: How to get the label value of current activity?

I have this attribute on one of my activities in my Xamarin project and I want to get the value of Label, which is "Requirements". How do I do that?

[Activity(Label = "Requirements", Icon = "@drawable/icon", Theme = "@style/MyTheme")]

Upvotes: 1

Views: 809

Answers (1)

A Springham
A Springham

Reputation: 2108

So this stackoverflow question shows how to do it in Android native. In C# for Xamarin you can do it like this:

var component = new ComponentName(this, Class.FromType(typeof(MainActivity)));
var activityInfo = PackageManager.GetActivityInfo(component, 0);
var label = activityInfo.NonLocalizedLabel;

Upvotes: 1

Related Questions