I'm going through training examples and I run on Android problem.
If I run this code on iPhone simulator I get the correct value and if I run it on Android I get null value.
L('add')
where 'add' is the key in mine i18n/en/strings.xml
Here is the whole method:
bh.ui.createBountyWindow = function(/*Boolean*/_captured) { var win = Titanium.UI.createWindow({ title : (_captured) ? L('captured') : L('fugitives'), activity : { onCreateOptionsMenu : function(e) { var menu = e.menu; var m1 = menu.add({ title : L('add') }); m1.addEventListener('click', function(e) { //open in tab group to get free title bar (android) var tab = (_captured) ? bh.capturedTab : bh.fugitivesTab; tab.open(bh.ui.createAddWindow()); }); } } }); win.add(bh.ui.createBountyTableView(_captured)); //if I call here L('add') on iPhone I get the value and on Android I get null if(Ti.Platform.osname === 'iphone') { var b = Titanium.UI.createButton({ title : L('add'), style : Titanium.UI.iPhone.SystemButtonStyle.PLAIN }); b.addEventListener('click', function() { //open modal on iOS - looks more appropriate bh.ui.createAddWindow().open({ modal : true }); }); win.setRightNavButton(b); } return win; };
The official code is here.
Other strings are OK on both platforms but they are called from different methods but I don's see why that matters. Any ideas?
2 Answers
EDIT:
The problem is somewhere else. This is really strange.
Here is the strings.xml file:
<?xml version="1.0" encoding="UTF-8"?> <resources> <string name="fugitives">Fugitives</string> <string name="captured">Captured</string> <string name="add">Add</string> <string name="capture">Capture</string> <string name="delete">Delete</string> <string name="busted">Busted!</string> <string name="still_at_large">Still At Large</string> <string name="new_fugitive">New Fugitive</string> </resources>here is the code:
logger.info(L('fugitives')); logger.info(L('captured')); logger.info(L('add')); logger.info(L('capture')); logger.info(L('delete')); logger.info(L('busted')); logger.info(L('still_at_large')); logger.info(L('new_fugitive'));here is the output on Android:
I/TiAPI ( 1625): (kroll$1: app://app.js) [669,2084] Fugitives I/TiAPI ( 1625): (kroll$1: app://app.js) [1,2085] Captured I/TiAPI ( 1625): (kroll$1: app://app.js) [4,2089] null I/TiAPI ( 1625): (kroll$1: app://app.js) [4,2093] null I/TiAPI ( 1625): (kroll$1: app://app.js) [2,2095] null I/TiAPI ( 1625): (kroll$1: app://app.js) [3,2098] null I/TiAPI ( 1625): (kroll$1: app://app.js) [3,2101] null I/TiAPI ( 1625): (kroll$1: app://app.js) [2,2103] nullHere is the output on iPhone:
[INFO] Fugitives [INFO] Captured [INFO] Add [INFO] Capture [INFO] Delete [INFO] Busted! [INFO] Still At Large [INFO] New Fugitive
WHAT IS SO DIFFERENT IN THOSE STRINGS ON ANDROID???????????
So the answer is so simple....
Project -> Clean
Now why is that? Could someone explain me what is going on in the background that Clean fixed?
Your Answer
Think you can help? Login to answer this question!