I am making application which requires to implement TableView.
I want to apply background image to tableview.
Can anybody help me to resolve this issue.
I am using below code to create Table view
Titanium.UI.setBackgroundColor('#FFF');
var win = Titanium.UI.currentWindow;
var data = [
{title:'Owner Description:'+' '+Titanium.App.Properties.getString("latitude"),hasChild:false,color:'blue', selectedColor:'#fff', setFont:10},
{title:'TerminalDescription:'+' '+Titanium.App.Properties.getString("TerminalDesc"),hasChild:false},
{title:'Address:'+' '+Titanium.App.Properties.getString("address"),hasChild:false},
{title:'City:'+' '+Titanium.App.Properties.getString("city"),hasChild:false},
{title:'State:'+' '+Titanium.App.Properties.getString("state"),hasChild:false},
{title:'Zip:'+' '+Titanium.App.Properties.getString("Zip"),hasChild:false},
{title:'Surcharge Amount:'+' '+Titanium.App.Properties.getString("Charge"),hasChild:false},
];
var tableview = Titanium.UI.createTableView({
data:data,
opacity:'.4',
maxRowHeight:'20',
//Set BG transparent
backgroundColor:'transparent',
backgroundImage:'Default.png',
//Set row color - white
rowBackgroundColor:'white'
});
win.add(tableview);
any help will be appreciated.
If you want a single image as a background to the whole TableView. Have a backgroundImage set in the parent view and for TableView set the backgroundColor to transparent. Following is your code modified for the same:
var win = Titanium.UI.currentWindow;
setBackgroundImage('Default.png');
var data = [ ... ];
var tableview = Titanium.UI.createTableView({
data:data,
maxRowHeight:'20',
backgroundColor:'transparent', //Set BG transparent
rowBackgroundColor:'white'
});
win.add(tableview);
Reference
Related
I have a status bar app which shows a green circle in the status bar and alternates to a red circle every 10 seconds. It does this by using item.view = icon1; and item.view = icon2; to change the image. Initialised like this:
let item = NSStatusBar.systemStatusBar().statusItemWithLength(-1);
self.icon1 = IconView(imageName: "icon1", item: item);
self.icon2 = IconView(imageName: "icon2", item: item);
When you click on the green or red circle, a popover view with some settings I have made appears fine.
The problem is at each 10 second interval when the item.view changes to either the red or the green, the popover view closes and requires the user to click the green or red button again to show it.
How can I make the popover persist though status bar image changes and only disappear once the user clicks the red or green button again?
Here is my awakeFromNib() for the popover view:
override func awakeFromNib()
{
let edge = NSMinYEdge
let icon = self.icon
let icon2 = self.icon2
let icon3 = self.icon3
let rect = icon.frame
let rect2 = icon2.frame
let rect3 = icon3.frame
icon.onMouseDown = {
if (icon.isSelected)
{
self.popover?.showRelativeToRect(rect, ofView: icon, preferredEdge: edge);
return
}
self.popover?.close()
}
icon2.onMouseDown = {
if (icon2.isSelected)
{
self.popover?.showRelativeToRect(rect2, ofView: icon2, preferredEdge: edge);
return
}
self.popover?.close()
}
icon3.onMouseDown = {
if (icon3.isSelected)
{
self.popover?.showRelativeToRect(rect3, ofView: icon3, preferredEdge: edge);
return
}
self.popover?.close()
}
}
}
You have the popover attached to a view that is later removed from the view hierarchy. Instead of assigning a new view to NSStatusItem each time, use a single view and change it's properties to show different states (i.e. change it's image property).
Alternatively you can create an empty NSView and assign it to NSStatusItem view property. Then you can add and show your icons inside that view as needed. Make sure to attach the popover to this empty view instead of individual icons.
Put a breakpoint inside the popover class dealloc method to see the stack trace. You'll get a hint of why this is happening from that stack trace.
I am having some serious issues with the flip animation and am not able to point it out, I have two image view on one view i have two buttons while the other just has an image.
My issue is when i flip from image view to the second image view with the buttons, the button zoom to the center of the screen and then move down to their original place.
From past 3 days i am not able to locate any kind of help online hence finally i decided to post a question here, please help me out given below is the code for those buttons and my animations.
The buttons are actually an image view
var cardView = Titanium.UI.createImageView({
image : imageBackground,
opacity:1,
zIndex: 10
});
var cardBackView = Titanium.UI.createImageView({
image :cardImage,
opacity: 0.1,
zIndex: 20
});
// am then adding few image in cardView and assigning images to them as above
var doneImageView = Titanium.UI.createImageView({
image: './images/Done.png',
bottom: screenHeight*0.001,//1,
right: screenWidth * 0.0156,//10,
width: screenWidth * 0.223,//143,
height:screenHeight*0.0469, //45,
zIndex: 105
});
var revokeImageView = Titanium.UI.createImageView({
image: './images/Revoke.png',
bottom: screenHeight*0.001,//1,
right: screenWidth * 0.0156,//10,
width: screenWidth * 0.223,//143,
height:screenHeight*0.0469, //45,
zIndex: 105
});
// creating a container view to hold the cardView and cardBackView
var testView = Titanium.UI.createView();
// assigning click event to both the images
cardBackView.addEventListener("click", function(e) {
testView.animate({
view:cardView, // doneImageView zooms on this animation
transition:Ti.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT,
duration:2500
});
});
cardView.addEventListener("click",function(e){
testView.animate({
view:cardBackView,
transition:Ti.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT,
duration:2500
});
});
// once done i have a container view where i am adding these images
// adding buttons image to the card view
cardView.add( doneImageView );
cardView.add( revokeImageView );
// adding the card view and card back view to the container view
testView.add(cardBackView);
testView.add(cardView);
// adding the container view to the main window
cardWindow.add(testWindow);
Please let me know what i am doing wrong here.
Thanks
I want to put an image from SQLite but the code below does't work:
var imageView = Ti.UI.createImageView({
image:services.fieldByName('image')
});
do this to convert the blob to a string before saving it
var stringToSaveInDatabase = Ti.Utils.base64encode(thumbBlob).toString();
when you are ready to add it to a view, do this
var imageBlob = Ti.Utils.base64decode(stringRetrievedFromDatabase);
Ti.UI.createImageView({ image:imageBlob });
http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.Utils-method-base64encode
Am using Tab group and using 4 tabs, 4 different windows are added to the tabs. when i try to get current window , by Ti.UI.currentWindow in any of the views which is added to windows, am getting blank value, that is it is not returning, current window value.
Can anyone correct me??
you set "url" property in Window on creation time. Like
in "app.js"
var tabGroup = Titanium.UI.createTabGroup();
var win_home = Titanium.UI.createWindow({
url :'home.js',
backgroundColor :'#000',
backgroundImage :'image/bg_img1.png',
barColor : "#000000",//"#ff429c"
});
var tab_home = Titanium.UI.createTab({
index : 0,
window:win_home
});
tabGroup.addTab(tab_home);
tabGroup.open();
in "home.js"
var cur = Ti.UI.currentWindow;
var view = Ti.UI.createView({
height : 100,
width : 100,
backgroundColor : "#0f0",
});
cur.add(view);
Understand this code and try to make like this. this is truly working... cheers...
I use Dojo Toolkit 1.7.2 from http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js
I need to show scrollable (with help touch) content inside dialog. Also, if possible, I will need to have transition between views inside dialog like at mobile too.
What I do (simplified version of code):
var dialog = new Dialog();
var view = new ScrollableView({
selected: true
});
//add some content inside view. Content heigh is greater than height of dialog.
If I do this, the dialog tries to fit the whole height of the content.
Next attempt:
var dialog = new Dialog({
style: {
width: 600,
height: 400
}
});
or
dialog.resize({w: 600, h: 400});
Now dialog has fixed height, but inner ScrollableView instance won't scroll to bottom of its content.
When I dig into the source, I find that ScrollableView inherits from dojox/mobile/_ScrollableMixin which inherits from dojox/mobile/scrollable.
The resize() function of dojox/mobile/scrollable uses window height in order to calculate scrolling functionality.
Is there some way to have what I need without implementating my own version of ScrollableView?
Solution:
var dialogRect = domGeometry.getMarginBox(dialog.domNode);
var headerRect = domGeometry.getMarginBox(dialog.titleBar);
var containerNodePaddingTop = domStyle.get(dialog.containerNode, "paddingTop");
var containerNodePaddingBottom = domStyle.get(dialog.containerNode, "paddingBottom");
var viewHeight = dialogRect.h - headerRect.h - containerNodePaddingTop - containerNodePaddingBottom;
var view = new ScrollableView({
selected: true,
height: viewHeight.toString() + "px"
});
// or
// view.set("height", viewHeight.toString() + "px");
Fixed it this way:
var Name = 'yourdialogid';
dojo.query("#"+Name+" .dijitDialogPaneContent").forEach(function(node, index, arr){
dojo.style(node,"overflow","auto");
dojo.style(node,"height",(dojo.position(dijit.byId(Name).domNode).h-80)+"px");
});