I am doing some pretty basic html displays using WebView and all is working well. One thing that I would like to do is as the user navigates between pages update the application label. I believe I'm calling it the correct name as Application label. This is the area where your string app_name is displayed via the manifest.
So anyway I would like to update it to say the tag of each page but I am not sure where to begin researching that type of interaction if it's possible. The other option as I've seen others do, but don't know how is to get my WebView to cover the application label area..or remove it or whatever it is they do. Once removed I'll just add a to my page displaying the .
TIA
JB
This is the area where your string app_name is displayed via the manifest.
My guess is that you are referring to the title bar (on older devices) or the action bar (on newer devices, plus older devices using ActionBarSherlock).
You can modify the text displayed there by calling setTitle() in your activity.
Related
I am building an app where in a Detail Activity I have to show a web page.
I was going to use WebView, but then I saw Chrome Custom Tab.
What do you guys think it's better to implement and why?
If you just want to show a certain page then I would suggest you use chrome custom tabs. You can style the toolbar in a way it resembles your app style and they are intended for showing content without you having to worry much about anything else.
if you want to have full control over what the user is doing inside this website you have to use a webview. (you can prevent the user clicking links on the webview, you could intercept data the user inputs into controls on the website...)
But this can also be a negative aspect since the user really has to trust you that you don't log his data or even fiddle with it.
summary: "The WebView is good solution if you are hosting your own content inside your app. If your app directs people to URLs outside your domain, we recommend that you use Chrome Custom Tabs"
-> If it isn't your website you probably should go with custom tabs.
https://developer.chrome.com/multidevice/android/customtabs#whentouse
Webview : If you want your own content which has click listeners and data interception you need to go to webview. But It wont share the state with the browser.
Chrome Custom tab : If You are just redirecting to a url, i prefer chrome custom tab. But it has little cons too. We wont change its title text color where we can change the titlebar color. The text color will be chosen by the theme color only. And We can add actions, but we cant change the overflow menu icon or the entire actions displayed in the overflow action.
Even though the limitation are not a big deal. I recommend chrome custom tab over webview.
When an email is selected for deletion in the GMail app, the ActionBar looks like so:
There is a check mark and selection count displayed, with a subtle entry and exit animation. It appears it's an overlay that's on top of the ActionBar or replaces it.
Since I don't know the name of this widget I have trouble finding info about it.
Is it part of the API? Google Calendar has a similar overlay when creating an event, which makes me think it's possibly part of the API.
If it is, what is it called?
How is the ActionBar updated with the row selection count? (No need for code, just a brief explanation would be helpful on how to write content to the the ActionBar overlay shown in the image).
Providing a partial answer to my own question. Hope this helps someone.
It's part of the API since Level 11 and is called contextual ActionMode. The idea is to enable the user to perform some specific action without leaving the Activity or Fragment. The references docs describe it like so:
Represents a contextual mode of the user interface. Action modes can be used to provide alternative interaction modes and replace parts of the normal UI until finished.
Android Developers have a section on it, saying:
The contextual action mode is available on Android 3.0 (API level 11) and higher and is the preferred technique for displaying contextual actions when available
There is a tutorial by Lars Vogella with a screen shot showing it's the same kind of overlay as seen in the GMail app.
Here is a screen shot from Android Developers (screen shot is licensed under Apache 2.0):
First it is not the part of the API and to update the count in action bar just add a listener for check box upon check increment the count and upon un-check decrements the count so simple :)
Update
alternately you can use this custom action bar
This seems crazy. I must be missing something. When setting location fragment in Android Browser (ICS, 4.0.3), the location bar fails to update to show the new fragment. Seems to fail equally whether setting window.location, window.location.hash, or a plain old <a href="#foo">. The browser does indeed navigate to the desired fragment, and on refresh, the location bar contains the fragment as expected. And the back button works! The only thing wrong is that the displayed address in the location bar should reflect the new location+fragment immediately, but it does not.
Good example can be seen at Google Closure goog.History demo page.
We noticed this too in Android 4.0.4.
Even worse is that at least on one Device (Galaxy Nexus) the hash navigation breaks if the url only contains a path e.g. http://www.example.com/path/. You can then navigate to fragment urls just fine, but tapping the back button has no effect.
The problem is fixed when a file is present in the url.
# will fail when using browser back button
www.example.com/path/
# will work although no fragment is shown
www.example.com/path/index.html
I have implemented my own manual method of switching the app's localization within the application without having to modify the device's localization settings. The user either clicks on a tabbed bar via a set of right nav buttons on iOS devices, or use the native menu on Android devices to select the desired language.
This method works great on iOS devices. It almost works great on Android devices in that all text labels are immediately set to the respective language after the user makes their selection. However, the native TabGroup tab titles are not changing on my Android devices. They change immediately on my iOS devices.
I've tried many different methods to try and work around this. I tried removing the existing tabs from the TabGroup, but Android doesn't support this, at least not while using Titanium. I tried closing the tabGroup then re-opening it, but this just causes my app to lock up. I also tried looping through all my tabs and setting the titles that way to no avail. I also attempted to use the splice() command on the tabs array of the tabGroup, and that just throws a TypeError complaining about not finding a default value for object.
This is becoming very frustrating. I've looked at custom tab options available, including the Titanium Marketplace module called Tabulous. I've not been thrilled with any of those alternatives, particularly with their poor horizontal layout performance or reliance on using images instead of a mix of images and text.
One thing I do know is that on Android devices, my tab titles are being changed, because, within my event listener where I set the tab titles on language selection, I can loop through the tabs in my tabGroup collection and output the titles which reflect the chosen language. However, Android for some reason does not redraw the tabs to show the new text.
Here's a snippet of my event listener where I set the tab titles:
Titanium.App.addEventListener('langChanged', function() {
homeTab.title = al.L('home_win_title');
servicesTab.title = al.L('services_win_title');
mediaTab.title = al.L('media_win_title');
contactTab.title = al.L('media_win_title');
// Android test:
if (Ti.Platform.name == 'android') {
for (var t in tabGroup.tabs) {
// The alert below returns the expected title based on the language selection!
alert(tabGroup.tabs[t].title);
}
}
});
As I said, on my test iOS devices, the tab titles are updated as expected. On Android devices, they do not change (are not re-drawn), though the alerts I throw in the above loop show the correct text.
Any ideas, anyone?
I ran into the same issue while also trying to support multiple languages in an app, and this post on the Appcelerator Q&A site appears to confirm that it's not possible to change the tab title on Android.
However I got around this problem by closing the tab group and opening a new one - so it is possible to do that, and it may be that you need to refactor some of your app to prevent the locking issue you mention.
Here's the part of the Manifest that I believe is important:
<application android:icon="#drawable/icon"
android:label="TestApplication"
android:theme="#android:style/Theme.Holo.Light">
<activity android:icon="#drawable/splashicon"
android:label=""
android:name=".Splash">
The splashicon is a 1x1 transparent png. When I try this way, the Application icon renders then fades to the transparent one.
I've tried various combinations of modifying the icon/label section for both activity and application and getting bad results. Removing the icon/label from the activity gives the most preferred result sans icon and label displaying during splash.
How do I get rid of those two items without messing up the icon/label in the app drawer and possibly other locations (haven't tested Market).
Edit:
I'm not after removing the icon/label from the app drawer (in fact, that is one thing I'm trying to retain).
The issue is that if I run the application in 3.0+, I get the icon and the label in the upper lefthand corner of the splash screen which is not what I'm wanting to see.
An example of an application that performs this behavior properly would be Pulse, Angry Birds Rio, and the like.
One application that I've noticed that falls victim to the same issue I'm having is Wyse PocketCloud Pro. If you run it in Honeycomb, look in the upper left hand corner as it is initially loading. Momentarily you can see the icon/label and it fades.
You need to be more specific about what you are looking for. I'll try to answer what you may possibly be asking for.
An activity that is being displayed in the launcher must have a label and icon. That's kind-of... well, it wouldn't make sense to not need these. So please don't play games here and try to not have them. You start to look like a malicious app by doing so.
If you don't want your activity to show up at all in the launcher, then don't declare the intent filter for the MAIN action and LAUNCHER category.
If you want the preview window when launching the app to look more like your real window (let's say you hide the title bar), then in the tag in your manifest use android:theme="..." to declare the theme you use so this can be used for the preview. For example, if you are using Theme.NoTitleBar to not have a title bar, do android:theme="#android:style/Theme.NoTitleBar".
If you want to show a splash screen for your app and have the preview window match it, and one of the standard themes does not match enough, then make your own theme and in the manifest specify it for android:theme. This will let you set a custom background color, or even set the background to an image that is your splash screen.
Keep in mind that launching applications should be fast, so having to show a splash screen every time it launches is very not desirable. On a mobile device, there is a good chance this will greatly reduce the amount your app is used because people won't wait for a long time for it.
If you are looking for something else, please update your question to more clearly state what it is.