I have created an Activity and declared in Manifest file. But I would like to re-use the same Activity for other purpose.
<activity android:configChanges="orientation|keyboardHidden" android:label="Main Menu" android:name=".MainMenu" android:theme="@android:style/Theme.Light" > </activity>
I need to change the Label dynamically. Thanks in Advance
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.
Go to the app > manifests > AndroidManifest. xml file and change the android:label field in your application node in AndroidManifest.
Yes, you can change the name of MainActivity by, opening the directory of the java file in android studio, right-click on it and find refactor, then rename, put in the name you like then click on refactor.
Use
setTitle(int titleId)
or
setTitle(CharSequence title)
public class YourActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { setTitle(R.string.your_title); setContentView(R.layout.main); } }
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