0
votes

I am developing an app in Titanium sdk 1.8.1and in this app I just create button with image but in android image is not display and its work fine iPhone. For android I have created folders high,low and medium inside resources folder so please give me idea how can i do that functionality.

var isAndroid = false;
if (Titanium.Platform.name == 'android') 
{
    isAndroid = true;
}
var addFriendButton = Ti.UI.createButton
({
    font:
    {
        fontFamily:'Helvetica Neue',
        fontSize:'15dp'
    },
    top:'20dp',
    left:'235dp',
    height:'22dp',
    width:'110dp',
    isButton:true
});

if(isAndroid)
{
    addFriendButton.backgroundImage = '../images/addfriend.png';
}
else
{
    addFriendButton.backgroundImage = path + '/Images/addfriend.png';
}

Thanks in advance.

1
Wot is that path variable contains, can you paste it over here ? - Triode
var path = Titanium.Filesystem.resourcesDirectory; and its return resource directory path and its work fine in iPhone but not display in android - Nikunj Jadav
its seems to be working for me ../assets/gradient-small.png i have a floder named assets under Resources and i am able to see the image, are you accessing this from your main app.js file or from some other file ? - Triode
I want to display image in tableview - Nikunj Jadav
sorry but its not working for me - Nikunj Jadav

1 Answers

1
votes

Yes, I got my issue just replace my code:

if(Ti.Platform.osname == 'android')
{
    addFriendButton.image = '/Images/addfriend.png';
}
else
{
    addFriendButton.backgroundImage = path + '/Images/addfriend.png';
}