Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I access android:label for an Activity

Tags:

Given

Android.xml:

<activity android:name='.IconListActivity'
  android:label='@string/icon_list_activity_name'
/>

Strings.xml:

<string name='icon_list_activity_name>Icon List</string>

How do I access to the string 'Icon List' given IconListActivity.class?

like image 832
Scott Avatar asked Sep 22 '09 02:09

Scott


People also ask

How do I change the activity label?

To change the title of an activity (to show a more custom title for a certain activity than the application title), you can set the new title either through calling setTitle("foo") on the activity or by setting android:label="@string/price_after_rebate" in your activity style.

What is activity tag android?

activity is the subelement of application and represents an activity that must be defined in the AndroidManifest. xml file. It has many attributes such as label, name, theme, launchMode etc. android:label represents a label i.e. displayed on the screen. android:name represents a name for the activity class.

How do I get activity stack?

This example demonstrate about How to get top activity name in activity stack. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.


1 Answers

PackageManager#getActivityInfo() returns an ActivityInfo structure, which has a labelRes and a name field, one of which should have what you need.

like image 165
CommonsWare Avatar answered Sep 24 '22 17:09

CommonsWare