Tableview graphic problem
Hi,
here's the screenshot of my problem :
and here's the code :
var win = Titanium.UI.currentWindow;
Titanium.UI.currentWindow.backgroundColor = '#C6CBD2';
/*
* ATTENTION
* VOICI LA METHODE POUR RECUPERER LE LOGIN ET LE MOT DE PASSE DE LA PERSONNE LOGGER
* ATTENTION
*/
var props = Titanium.App.Properties.listProperties();
for (var c=0;c<props.length;c++)
{
var value = Titanium.App.Properties.getString(props[c]);
if (props[c] == "email") {
var email = value;
}
if (props[c] == "pass") {
var pass = value;
}
}
/*
* Recherche en base de données locale
* pour avoir l'email de la personne connecté
*/
var db = Titanium.Database.open('mydb');
var row = db.execute('SELECT nom,prenom FROM pcuser where nummobile=? and motdepasse=?',email,pass);
var dataFields = [
{hintText:row.field(0), codename:"nom"},
{hintText:row.field(1), codename:"prenom"}
];
row.close();
var rows = {};
var fields = {};
var tableViewData = [];
function addTextFieldRow(data)
{
rows[data.codename] = Titanium.UI.createTableViewRow({height:45});
fields[data.codename] = Titanium.UI.createTextField({
color:'#000',
font:{fontSize:16, fontWeight:'normal'},
height:35,
top:5,
left:10,
width:data.width || (250),
hintText:data.hintText,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_NONE,
keyboardType:Titanium.UI.KEYBOARD_EMAIL,
returnKeyType : Titanium.UI.RETURNKEY_DONE
});
rows[data.codename].add(fields[data.codename]);
return rows[data.codename];
}
var emailTableViewContainer = Titanium.UI.createView({top:50});
win.add(emailTableViewContainer);
for (var i=0; i<(dataFields.length); i++)
{
tableViewData[i] = addTextFieldRow(dataFields[i]);
}
var emailTableView = Titanium.UI.createTableView({
data:tableViewData,
top:0,
style:Titanium.UI.iPhone.TableViewStyle.GROUPED
});
emailTableViewContainer.add(emailTableView);
// okButton
var enregistrer = Titanium.UI.createButton({
title:'Enregistrer',
style:Titanium.UI.iPhone.SystemButtonStyle.DONE
});
win.setRightNavButton(enregistrer);
As you can see, there's a white bar on the top, i don't know why, but i can't put anything in that bar.
what am I doing wrong ?
Thanks
1 Answer
-
Accepted Answer
You put your table inside a View with its 'top' set to 50…
var emailTableViewContainer = Titanium.UI.createView({top:50});
I don't see why the bar is white instead of transparent - seems like a Titanium bug to me - but the space is there because of the 'top' property.
If you want to keep the spacing but make it use the background properly, you might try adding a parent view to the top level:
var parentView = Ti.UI.createView(); var emailTableViewContainer = Titanium.UI.createView({top:50}); parentView.add(emailTableViewContainer); win.add(parentView);