I have an Activity defined in my manifest as:
<activity
android:name=".userhistory.UserHistory"
android:configChanges="orientation"
android:launchMode="singleTop"
android:label="User History">
</activity>
Now i want to get the value
of the label
attribute from within my activity code.
Is there any way i can do this ?
"Pseudo"-code:
PackageManager PM = getApplicationContext().getPackageManager();
PackageInfo PI = getPackageManager().getPackageInfo(getPackageName(), 0);
String strLabel = PI.applicationInfo.loadLabel(PM).toString();
strLabel
will contain the value in android:label
from your AndroidManifest.xml
.
use string.xml to save your all string like following
<resources>
<string name="activity_name">User History</string>
</resources>
then use it any where in your other xml like this
.android:label="@string/activity_name"
and you can use it in activity like this
String activityname= getString(R.string.activity_name);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.