[TIMOB-3179] Android: Tab icons should support resource ids
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Trivial |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T02:01:07.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Sprint-2011-08 |
Components | Android |
Labels | android, feature, release-1.7.0, reported-1.5.1, rplist |
Reporter | Bill Dawson |
Assignee | Don Thorp |
Created | 2011-04-15T03:38:53.000+0000 |
Updated | 2011-04-17T02:01:07.000+0000 |
Description
Now that we expose Ti.Android.R
we should allow
resource ids instead of paths to the icon
property of
tabs.
Excerpt from http://developer.appcelerator.com/helpdesk/view/73511">HD:
I've put a {root}/platform/android/res/drawable directory in place.
In there I've put in a state-list-drawable XML file for each of my tabs following the naming convention "ic_tab_tabName1.xml"
I've then put in corresponding {root}/platform/android/res/drawable-{ldpi/mdpi/hdpi} directories with appropriately sized icons for both the selected and unselected states.
Then when I create the tab, my call looks something like this:
var tab1 = Titanium.UI.createTab({
icon:Titanium.Android.R.drawable.ic_tab_tabName1,
title:'Tab 1',
window:win1
});
tabGroup.add(tab1);
So, this doesn't work... At runtime I get an exception like this:
[TRACE] E/TiUncaughtHandler( 429): java.lang.ClassCastException: org.appcelerator.titanium.proxy.RProxy
[TRACE] E/TiUncaughtHandler( 429): at ti.modules.titanium.ui.TabGroupProxy.addTabToGroup(TabGroupProxy.java:163)
Thanks for reporting this, Bill. I'm also wondering if there should be an over-all assessment of the entire API to address all the various properties where @drawable resources could/should be allowed as values (and correspondingly, properly resolved in the native layer)?
Also, I've noticed in an app I'm currently working on that if I do use Ti.Android.R.xxx I receive an "no such method for [undefined]" javascript error in iOS EVEN IF I go through the trouble of using a Ti.Platform.osname-based resolver (e.g. like the tt.os utility method in the Tweetanium app). This totally makes sense since the whole Ti.Android.xxx namespace is unresolved in the iOS build configuration.
BUT, this makes coding much more complicated because I have to revert back to encapsulating such references in their own include files and then doing conditional-wrapped Ti.Platform.osname switching. Is there any way we can make this more graceful w/r/t supporting multi-target app development?
Thanks,
Etienne
Yes, we're looking at it for the whole api.
Re your other problem: be sure to put it in Helpdesk so our Support guys can try to help you.
Test Case for QE:
From the project's root folder, create the folder
platform/android/res/drawable
.Plop the two .pngs here -- selected.png & unselected.png -- into the
platform/android/res/drawable
folder.Save the following xml as
platform/android/res/drawable/ic_tab1.xml
:In the "old" version (pre-commit), the app will crash immediately. If you look at logcat you will see a
ClassCastException
similar to:With the post-commit version, you should see that the first tab has a bird icon when selected, and a star icon when not selected (i.e., when the other tab is selected).
removed tbs-1.7.0 added release-1.7.0
don't know why this didn't get updated with my commits. Here they are:
https://github.com/appcelerator/titanium_mobile/commit/dddf612e49194b97f1522fc53e3c3ea22a842dd5"> https://github.com/appcelerator/titanium_mobile/commit/dddf612e4919...
https://github.com/appcelerator/titanium_mobile/commit/979a1c50a695a03a442be2446c411835ac39148d"> https://github.com/appcelerator/titanium_mobile/commit/979a1c50a695...
Tested with Titanium SDK version: 1.7.0 (03/01/11 16:09 e613126)
GalaxyTab 2.2
Emulator 2.1