I am working on my very first app in Titanium Studio.
So my project consists of an login page and if the login is successful a tableview will populate the screen.
The problem I enconter is, on the Titanium emulator the app works OK, but when I installed on a device, the two textboxs and the button are missing.
Do you have any ideas what I am doing wrong ?
For mobile web, the app works just fine.
Thanks.
The code :
var win = Titanium.UI.currentWindow;
var username = Titanium.UI.createTextField({
color:'#336699',
top:10,
left:10,
width:300,
height:40,
hintText:'Username',
keyboardType:Titanium.UI.KEYBOARD_DEFAULT,
returnKeyType:Titanium.UI.RETURNKEY_DEFAULT,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(username);
var password = Titanium.UI.createTextField({
color:'#336699',
top:60,
left:10,
width:300,
height:40,
hintText:'Password',
passwordMask:true,
keyboardType:Titanium.UI.KEYBOARD_DEFAULT,
returnKeyType:Titanium.UI.RETURNKEY_DEFAULT,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(password);
var loginBtn = Titanium.UI.createButton({
title:'Login',
top:110,
width:90,
height:35,
borderRadius:1,
font:{fontFamily:'Arial',fontWeight:'bold',fontSize:14}
});
win.add(loginBtn);
for android,
try to remove property borderStyle. its for iphone only.
and also comment borderRadius and font property for button and try. If you want to use borderRadius then you need to set other two relative properties for that . borderWidth and borderColor.
to use custom font , you need to first configure it so just try to comment that property and try.
Related
I have a project that simply displays a website. My code is:
function pencere() {
var self = Ti.UI.createView({ width:"100%", height:"100%" });
var webPencere = Ti.UI.createWebView({ left:1, right:1, top:1, bottom:1, url:"http://www.radyobasaksehir.com" });
self.add(webPencere);
return self;
}
My friend told me that the Android browser doesn't support the new CSS and HTML codes. I don't know the exact meaning of these but I think I need to revise my code but I couldn't figure that out.
The problem is related to chromium WebView being used Android 4.4.
There is developed a module for solving this. But, I found advice here in another topic
Just add borderRadius property with a minimum value. Sample code:
var webview = Ti.UI.createWebView({url: '..', borderRadius: 1});
My engironment is titanim 6.0.1.GA
It doesn't show the label on Android, while iOS show the label correctly.
var descriptionView = Ti.UI.createView({
height:'100%',width:'100%'
children:[Ti.UI.createLabel({
wordWrap :true,top:0,
color:'black',
text:"my label",
})]
});
It works well both on Android/iOS
var descriptionView = Ti.UI.createView({
height:'100%',width:'100%'
});
var label = Ti.UI.createLabel({
wordWrap :true,top:0,
color:'black',
text:"my label",
});
descriptionView.add(label)
I just wonder using children is bad behaivor for andorid?
However it sometimes very useful to simplify the code.
Is there anyone who uses children successfully for Android??
According to the titanium API 'Children' property is a read only property and it should not be used to set data. It's considered to be good luck as it's working with IOS but with Android we need to be specific with the code.
I would never suggest you to use this coding style to simplify the code, rather you could use the following to simplify and also memory effective way :
var descriptionView = Ti.UI.createView({
height:'100%',width:'100%'
});
descriptionView.add(Ti.UI.createLabel({
wordWrap :true,top:0,
color:'black',
text:"my label",
}));
Good luck,
Cheers
I have an image view and try to load remote image but it's can not show up.
I'm already search and try any suggestion on this forum but not work. I'm using SDK 3.2.2 on Mac OS X Maverick
My code is like here, and it's running good on iOS.
var iconImage = Ti.UI.createImageView({
width:40,
height:40,
left:5,
hires:true,
defaultImage:'/images/default.jpg',
image:urltoimage
});
sample image
this is a bug or something wrong with my code?any suggestion how to do remote image? Please help..
Use this
exports.LoadRemoteImage = function (obj,url) {
var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function()
{
Ti.API.info('image data='+this.responseData);
obj.image=this.responseData;
};
// open the client
xhr.open('GET',url);
// send the data
xhr.send();
};
save on new file and named "ImageLoader.js"
I'm forget where I found that code, but I'm used that to handle any image from internet.
usage:
var ImageLoader = require('ImageLoader');
var imageView = Ti.UI.createImageView({
width:100,
height:100
})
ImageLoader.LoadRemoteImage(imageView,"http://i1314.photobucket.com/albums/t567/vademahendra/sightseeing_zpsd91fa049.png?t=1401680320");
I hope this can help you
I've run application with this code:
var urltoimage = 'http://i1314.photobucket.com/albums/t567/vademahendra/sightseeing_zpsd91fa049.png?t=1401680320';
var win = Ti.UI.createWindow();
var iconImage = Ti.UI.createImageView({
width: 40,
height: 40,
left: 5,
hires: true,
defaultImage: '/images/default.jpg',
image: urltoimage
});
win.add(iconImage);
win.open();
All worked properly, so the issue has to be on your device or simulator.
Check network connection and if airplane mode is enabled.
Does it show up on the device and just not on the emulator, or does it not show up at all?
Sometimes Android can be temperamental about remote images. CDNs usually work really well which is probably why daniula's code worked. Things to try are:
Change the pixel dimensions of your remote image to be smaller - test
Change the image file size of course using different compressions - test
Try different file types
Try using the same image url daniula used to see narrow it down to the image or the code: if the images shows up, then it's a problem with the serving of the images; if the image does not show, it may be an issue with your code.
I am fresher in titanium for mac os x.
I am using titanium first time and do not have any knowledge on js pages and action event's
I am setup titanium and add button. On button click i need to navigate to another js page
and this project will run into iPhone and android device
if you are newbie then kitchensink is best practice to learn titanium.
in app.js file write
var win = Ti.UI.createWindow({
backgroundColor : 'red'
});
win.open();
var button = Ti.UI.createButton({
title : 'click me to open new window'
});
win.add(button);
button.addEventListener('click', function(e){
var newWindow = Ti.UI.createWindow({
url : 'newWindow.js',
backgroundColor : 'white'
});
newWindow.open();
});
I am developing an app in titanium, and completed the iOS version successfully. Android is presenting some problems, here is one.
The view contains a number of labels to display data in the format
A:B (note that B is bold). That bold part is necessary, and the reason I need two labels.
This is the code I am using:
if(restaurant && !(restaurant=='no' && restaurant.length=='2')){
var restaurant_label = Ti.UI.createLabel({
text:'Restaurant:',
left:3,
height:20,
width:'auto',
top:0,
textAlign:'left',
color:'#000',
font:{
fontFamily:'Helvetica Neue',
fontSize:13,
fontWeight:'Regular'
}
});
view.add(restaurant_label);
var restaurant_value = Ti.UI.createLabel({
text:restaurant,
left:restaurant_label.width+10,
height:'auto',
width:'auto',
top:-18,
textAlign:'left',
color:'#000',
font:{
fontFamily:'Helvetica Neue',
fontSize:13,
fontWeight:'Bold',
fontStyle:'Italic'
}
});
view.add(restaurant_value);
check_localservices = false;
}
The "value" label needs to be in the right spot, but android does not seem to be able to get the width of the previously added label.
What gives?
It appears in a bug report that there was some question as to what it suppose to be reported by a label.width query. According to the bug report for version 1.7, a correct response to YOUR query should return 'auto' on Android. This is the case because you have 'auto' as the value for width. Does it return 'auto'?
https://jira.appcelerator.org/browse/TIMOB-3202
It so happens that it looks like the correct code is listed there to get the value you are looking for. I haven't tested this, but it appears you might be querying the wrong value.
For your situation it appears you want to use:
var restaurant_value = Ti.UI.createLabel({
text:restaurant,
left:restaurant_label.size.width+10, // <===== size
height:'auto',
width:'auto',
top:-18,
textAlign:'left',
color:'#000',
font:{
fontFamily:'Helvetica Neue',
fontSize:13,
fontWeight:'Bold',
fontStyle:'Italic'
}
});
According to the comments, you might need to also query the size property after 'opening' the window. If you look at Paul Dowsett's answer, he has an example of a listener on the 'open' event.