When i create textfields by hand and adding them to the table field makes them invisible. Only after i scroll down and back up they appear, why is this happening ? And what can i do to make them show directly?
Here is the code:
/** * @author radjoe */ // // File to create a New Contact // Ti.include('androidUI.js'); // this sets the background color of the master UIView (when there are no windows/tab groups on it) Ti.UI.setBackgroundColor('#000'); // // Properties // winEditContact = uiElements.Window('Edit a contact', 'androidMainMenu.js'); var editContactTableView = uiElements.TableView(); var data = []; var UserData = JSON.parse(Ti.App.Properties.getString("profile")); var textFieldArray = []; var personalHeader = uiElements.TableViewHeader('Personal information'); data.push(personalHeader); // ETC ETC... this goes on for all textfields var firstName = uiElements.TextField(); firstName.width = '95%'; firstName.top = 30; firstName.hintText = 'Firstname'; if(UserData.Firstname != null && UserData.Firstname != ''){ firstName.value = UserData.Firstname; } textFieldArray[0] = firstName; // Even this button shows up invisible, why ??? var btnCreateContact = uiElements.Button('Save changes'); btnCreateContact.width = '95%'; btnCreateContact.height = 50; btnCreateContact.top = 5; // This fails to var test = uiElements.TableViewRow('fn', false); test.add(firstName); data.push(test); // Eventlisteners // Function initiate function initiate(){ var textFieldLoop = 0; while(textFieldLoop <= 10){ var sumRow = uiElements.TableViewRow('here goes text for classname etc'.hintText, false); // LABEL DOES SHOW IMMIDIATLY!!! var title = uiElements.Label(); title.text = textFieldArray[textFieldLoop].hintText; title.font = { fontSize: 20, fontWeight: 'bold'}; title.height = 28; title.top = 2; title.left = 10; sumRow.add(title); sumRow.add(textFieldArray[textFieldLoop]); data.push(sumRow); if(textFieldLoop == 10){ var btnRow = uiElements.TableViewRow('Detail', false); btnRow.add(btnCreateContact); data.push(btnRow); editContactTableView.data = data; winEditContact.add(editContactTableView); } textFieldLoop++; } } // Open window Ti.UI.currentTab.open(winEditContact, {animated:true}); initiate();The strange thing is, when i create a new textfield in the while loop, the textfields are shown in the tableview.
The purpose of this is to fill in textfields and get the data to create a new Contact.
Since i failed to create a scrollable window with these textboxes i tried a tableview, but this is also failing.
Help is appreciated, tnx
1 Answer
So after some long debugging i found out that:
textField.width = '95%';this is causing invisible textfields, but why? Anyone knows how to still use this property and having visible textfields?
Your Answer
Think you can help? Login to answer this question!