I have one activity and three intet filters, each with different label set on, (AndroidManifiest.xml below)
<activity android:name=".activities.RecordActivity">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="com.keitai.enigma.OPEN_RECORD" />
</intent-filter>
<intent-filter android:label="#string/newRecord">
<category android:name="android.intent.category.DEFAULT" />
<action android:name="com.keitai.enigma.NEW_RECORD" />
</intent-filter>
<intent-filter android:label="#string/editRecord">
<category android:name="android.intent.category.DEFAULT" />
<action android:name="com.keitai.enigma.EDIT_RECORD" />
</intent-filter>
</activity>
But activity title is not changing to label set in intent filter :( Activity always contains application label.
What I'm donig wrong?
Are you sure you don't have code that is setting the title explicitly?
Are you sure that the OPEN_RECORD intent isn't the one being triggered every time?
Have you tried debugging by making sure everything has a distinct label (application, activity, each intent-filter) and seeing what happens?
I agree with you that what you expected to happen is what the docs say should happen. But it seems like the default <application> label is being used regardless. I'm afraid if one of the above ideas doesn't help, then I'm out of ideas. I might try it myself later on my system to see if it happens for me.
http://developer.android.com/guide/topics/manifest/intent-filter-element.html#label
android:label
A user-readable label for the parent component. This label, rather than the one set by the parent component, is used when the component is presented to the user as having the capability described by the filter.
...
The default value is the label set by the parent component. If the parent does not specify a label, the default is the label set by the element's label attribute.
http://developer.android.com/guide/topics/manifest/manifest-intro.html#iconlabel
Icons and Labels
...
In every case, the icon and label set in a containing element become the default icon and label settings for all of the container's subelements. Thus, the icon and label set in the element are the default icon and label for each of the application's components. Similarly, the icon and label set for a component — for example, an element — are the default settings for each of the component's elements. If an element sets a label, but an activity and its intent filter do not, the application label is treated as the label for both the activity and the intent filter.
...
You use intents usually to pass information between activities, apps or services (just few examples).
My understanding is, that you want to change your title of one activity depending on e.g. if a button is pressed.
Therefore you need to set simply in your activity
this.setTitle("YOUR ACTIVITY NAME");
In case you want this to happen after a button click, put it into the listener of the corresponding button.
Actually, from your example I'd suggest that you use separate activities (which can specify labels that are shown as titles!).
In Android, one activity usually corresponds to one use case - so if OPEN_RECORD shows a dialog where the user can select a record and EDIT_RECORD allows to edit a record, than you would usually have two different activities.
Have a look at the notepad tutorial for an example.
Related
i want to change the app name. Not every where. only in the launcher screen of an android.
Not inside the app or in the installation screen.
is this possible?
Your Manifest.xml file should be similar to this:
<application
....
<activity
android:name=".activities.SplashScreenActivity"
android:label="myLabel"
android:screenOrientation="portrait"
android:theme="#style/SplashTheme">
....
....
As you can see every Activity node has a label attribute. Changing this changes only the activity label (not all over the application)
Set the android:label attribute of the main Activity in your Android Manifest (the one that starts when the Launcher icon is pressed)
When reviewing my app, I noticed that the blue bar on the top and the text in the bar (the project name) does not fit in the app.
I tried changing the project name into a more relevant one by going into REFACTOR -> RENAME but it said 'can't rename root module.' every time I tried to.
Is there a way I can either delete the blue bar or change the text on it?
Are you familiar with the resources strings object? Let me know if this makes sense... Look at the image that I've included. Go to res/values/strings.xml and make the app_name tag be empty
<string name="app_name"></string>
Project name for Toolbar is defined in res/values/strings with key app_name by default.
In strings.xml, change app_name.
Or there's a setText method on the ActionBar class
To remove the bar depends on the theme used by that Activity (or if you explicitly show a Toolbar in the XML layout)
The name of your app is defined in your AndroidManifest.xml. Inside, you'll see an Application object, with a property of ApplicationName. Set this to whatever you want.
for remove top bar use in Manifest file :
<application ....
android:theme="#style/Theme.AppCompat.Light.NoActionBar"
>
The title of the action bar (your blue bar on the top) is set inside you AndroidManifest.xml, inside the activity tag:
<activity
android:name=".activity.MainActivity"
android:exported="true"
android:label="#string/app_name" >
</activity>
A good practice is to refer to a string stored inside Strings.xml
<string name="app_name">My cool app</string>
getActionBar().setTitle("TITLE");
OR
getSupportActionBar().setTitle("TITLE");
I have an intent that makes a call and then the call event start; I want to set background layout for that Make_Calling screen
Can anyone help me?
"Set layout for this(Image) call make screen!!"
Thanks in Advance
Like the above(2nd) image...
Pretty much easy... In layout file there will be a LinearLayout or RelativeLayout or FrameLayout. use android:background attribute and pass drawable in it.
The layout xml has a attribute background. You can set in xml or do the same in code as well. android:background="#drawable/image.png"
You want to customize the default calling or incoming screen if I am right. It is not possible to customize the default screens. However, you will be able to replace the default screen with your own view. You can create an activity which calls your customised view and add the intent to the Activity in the Manifest file, similar to below
<activity class=".MyCustomCallActivity" android:label="#string/mycustomcall_title">
<intent-filter>
<action android:name="android.intent.action.ANSWER" />
</intent-filter>
</activity>
Read Intent for more details on how to handle intents
I am new to implement the ListView with section.
I have use this application to implement the section to my list view.
Now I want to add the Titlebar that display the application page title. Then where do I have to make a change? In the xml file or in the Java file?
Please refer the example and let me tell what should I have to change to make Titlebar for my app.
Try this...
final Activity activity = this;
activity.setTitle("Settings");
if you disabled the title bar using, this.requestWindowFeature(Window.FEATURE_NO_TITLE);
remove it.
(OR)
Try this..
final Activity activity = this;
this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.settings);
activity.setTitle("Settings");
There are two ways to change title bar for your activity:
Design time (that is, change title in AndroidManifest.xml file).
By coding (that is, you can code to change the activity title).
Example for 1st:
you can Change the Title of each screen (i.e. Activity) by setting their Android:label inside the AndroidManifest.xml file:
<activity android:name=".Hello_World"
android:label="This is the Hello World Application">
</activity>
And yes, to display customized title bar for your activity, go through this answer: How to change the text on the action bar
In your AndroidManifest.xml file you have a section for each activity that looks like this
<activity
android:label="Your Activity"
android:name=".YourActivity" />
where the android:label tag defines what the text in the titlebar is.
Hallo everybody,
I'd like to use black color as default text color only in one activity.
I guess, I should use Theme and Styles, but I didn't find any good information relating to my question or to only one activity.
Is it possible to change default text color only for one activity?
If yes, could you give me an example please, how to do this?
Mur
You can add the android:theme tag to just an activity:
<activity
android:name=".SomeActivity"
android:theme="#style/Theme.ForSomeActivity"
/>