Android How to change the application title - android

HI
I need to change the application title as when i move to new tab.
i tried to change the app_name with varying string in string.xml but that is not actual dynamic change that i want.
is there any alternative way of doing this?

You can simply call the setTitle() function from within your Activity. It takes either an int (resource ID) or a CharSequence as a parameter.

android:label in AndroidManifest.xml is using reference to #string/app_name for user readable application name (app name in applications list or name under icon on main screen if you add shoutcut)
For changing Activity title you should use setTitle() of Activity class.

then you have to set the custom title for your app. check my post.
You have to set a custom layout for your title. you can access the TextView object from that.
Edit:
Accept Apologize. i didnt read the question propely.
setTitle() method is enough. My answer is about to customizing the title.that is color, text size and all.

Related

Android Change Color Resource Value Programmatically

I am making an app and was wondering if there was a way to change a color resource value programmatically. For example, I am using the resource R.color.text_color_name to set the TextView text color. Is there a way to set that value to something different so that it would change the color of every TextView in the application?
The R file contains constants, you cant change them at runtime because you can't normally change constants at run time. If you want to update the color of all textviews why dont you look into themes. Create a custom theme and then change the theme when activity loads in onCreate. After you set the new theme i think your going to have to call setContentView again and then call all your findViewByIds again as they will be null. You could also try Calling recreate() after setTheme(). This sounds messy.
Maybe this can help you change the theme.

Modify Android Theme Programmatically

A similar question to this has been asked many times; however, an answer has not been given that addresses my situation. I need to dynamically change an application's theme based on color values that are being returned from an API call. I then need to change the theme colors of the app based on the values returned. Therefore, I have no way of saving the colors in a style XML file. Can this be done?
I have a base activity, and my plan is to set the app theme from there for all the activities.
Unfortunately, I did not find an easy way to do this. I created a ThemeColor class which holds all the colors returned by the API. Then for each activity I have to go through every widget and style it.
Example:
getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(themeColor.getActionBarColor)));
this.getWindow().getDecorView().setBackgroundColor(Color.parseColor(themeColor.getBackgroundColor()));
etc
I was not able to locate a simple way to resolve this issue either. By creating a ThemeColor class that holds all the colors returned from the API. Next for each activity I needed to address each widget separately as well as style it.

Android System Resources Get Text dynamically

I would like to set some specific system settings of android within my application.
Is it possible to get the text and maybe also a description of the settings resources by code?
For instance I would like to allow to change this setting:
android.provider.Settings.System.SCREEN_BRIGHTNESS
In the android settings it appears Brighness. This resource is localized as well, so I do not want to do the same thing within my appliacation.
I would like to create a button and insert the text dynamically, if possible.
If someone has a hint were to look at, please help.
Best Regards,
Patrick
android.provider.Settings.System.SCREEN_BRIGHTNESS In the android
settings it appears Brighness. This resource is localized as well, so
I do not want to do the same thing within my appliacation.
See this: Settings.System. If you want the value localized, use an integer resource in folders with language and/or locale qualifiers. See Integer Resource and Alternative Resources
I would like to create a button and insert the text dynamically, if
possible.
Define as much of the layout as possible in xml, calling setContentView() on the name of the xml file. The button can then be referenced after the call with (Button)findViewById() using the id as given in xml. You can then set text dynamically and modify the widget further in code. See Layouts and TextView setText, which works for Button since Button extends TextView.
Hope this helps.

Android: programmatically change the application label?

It doesn't seem possible, but I was hoping someone may be aware of a way. Can the label of the application (the one defined in the manifest file by android:label="#string/app_name") be set from code?
That is read-only, AFAIK.
If your objective is to change the title bar of your activities, you can call setTitle().
I mostly use this to change actionBar's text pragmatically in onCreate() method....very easy!
getSupportActionBar().setTitle("yourString");
I used:
this.setTitle("YourString");

Set application label in java code instead in AndroidManifes

Is it possible to set label for application in java code instead in AndroidManifes, I mean the displayable name of application not just title of activity.
I don't think you can, as per the answer to this related question.

Categories

Resources