Hi guys, I'm working on comment system like the one in Facebook app, I've got a tableView, a scrollView and an input TextField. Every time I click on my textField and keyboard appears, my entire window lifts up :( Here my code and two images.
Hope someone will help!
function ChatWindow(id_poi,title) { var _this = this; this.title = title; this.id_poi = id_poi; this.window = Ti.UI.createWindow({ title: "Commenti", fullscreen:false }); this.window.windowSoftInputMode = Ti.UI.Android.SOFT_INPUT_ADJUST_PAN; this.window.addEventListener('android:back', function() { this.close(); }); this.window.activity.onCreateOptionsMenu = function(e) { var actionBar = this.window.activity.actionBar; actionBar.displayHomeAsUp = true; actionBar.onHomeIconItemSelected = function () { this.window.close(); }; }; this.downloadData(this.window,id_poi); return this.window; } ChatWindow.prototype.downloadData = function(window,id_poi) { this.window = window; this.id_poi = id_poi; var commentReq = Titanium.Network.createHTTPClient(); commentReq.open("POST","http://www.giacomomarangoni.com/log/comments.php"); var params = { id_poi: id_poi }; commentReq.send(params); var response; commentReq.onload = function(){ var json = this.responseText; response = JSON.parse(json); configureWindow(window,response); }; }; function configureWindow(window,response) { this.window = window; this.response = response; var larghezza_schermo = Ti.Platform.displayCaps.xdpi; var data=[]; //la tabella probabilmente deve essere messa in una scrollview perchè altrimenti se compare la tastiera non si vede la parte superiore var TheTable = Titanium.UI.createTableView({ rowHeight: 'auto', height:'auto', top:0 }); for (var i = 0; i < response.length; i++) { var row = Titanium.UI.createTableViewRow({ height: 'auto', }); //eventuale foto profilo /*var profile = Titanium.UI.createImageView({ url:response[i].profile_pic, width:32, height:32, left:4, top:8 });*/ var name = Titanium.UI.createLabel({ text:response[i].nome_completo, font:{fontSize:16,fontWeight:'bold'}, width:'auto', textAlign:'left', top:8, left:10, height:'auto', }); var comment = Titanium.UI.createLabel({ text:response[i].commento, font:{fontSize:14,fontWeight:'bold'}, width:'auto', textAlign:'left', bottom:10, top:28, left:10, right:10, height:'auto', }); //row.add(profile); serve per aggiungere la foto profilo row.add(name); row.add(comment); row.className = 'comment_row'; data.push(row); } var scrollView = Titanium.UI.createScrollView({ contentWidth:'auto', contentHeight:'auto', top:0, showVerticalScrollIndicator:true, showHorizontalScrollIndicator:false }); window.add(scrollView); TheTable.setData(data); scrollView.add(TheTable); var textField = Titanium.UI.createTextField({ color:'#336699', height:40, left:0, width:larghezza_schermo-25, bottom:0, hintText:'Inserisci un commento', keyboardType:Titanium.UI.KEYBOARD_DEFAULT, returnKeyType:Titanium.UI.RETURNKEY_DEFAULT, borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED }); scrollView.add(textField); var sendButton = Titanium.UI.createButton({ title:'Invia', width:60, height:40, borderRadius:1, bottom:0, right:0, font:{fontFamily:'Arial',fontWeight:'bold',fontSize:16} }); scrollView.add(sendButton); }; module.exports = ChatWindow;