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?
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.
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.
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.
PackageManager#getActivityInfo()
returns an ActivityInfo
structure, which has a labelRes
and a name
field, one of which should have what you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With