Hi everbody,
I have a problem with TableView and TabGroups.
My Application (for IOS and Android) is very simple. I have a TabGroup with 3 diffrent views attached to them. The second one is called SignallQuelle (SignalSource)
In this view there is a button which will retrive data via Rest on a Server. If you open this tabgoup the first time this button calls receiveSignalquelle and then in this methode i convert the response into rows for the TableView and then i write it to $liegenschaften_list which is the mentioned tableView.
the funny part starts then. If you go in the Tabgroup to Signalquelle and press the button the function does exactly what it should and you see the result.
If you leave the tabGroup and reopen it again the data is empty ( no rows visable) if you press ist again you get a nullpointer exception
Here is the Code
function receiveSignalquelle(event) { var json = JSON.parse(event.response); if (json.signalquelle != undefined) { var signalquelle = convertJson.convertSignalquelle(json.signalquelle); signalquelle.save(); Ti.API.log("Signalquelle: " + signalquelle.get('id')); } if (json.liegenschaften != undefined) { var lSignalquelle; var row; var rows = []; for (var i = 0; i < json.liegenschaften.length; i++) { lSignalquelle = convertJson.convertLiegenschaftenFromSignalquelle(json.liegenschaften[i], signalquelleNr); lSignalquelle.save(); row = Alloy.createController('IR/IR_SignalquelleLiegenschaft', { liegenschaftNr : lSignalquelle.get('LIEGENSCHAFT_NR'), liegenschaftAdresse : lSignalquelle.get('LIEGENSCHAFT_ADRESSE') }).getView(); rows.push(row); Ti.API.log("Liegenschaft Nr: " + lSignalquelle.get('LIEGENSCHAFT_NR')); }; } $liegenschaften_list.data = rows; // Felder setzen $.signalquelleInformation_anschrift.text = signalquelle.get('SIGNALQUELLE_STRASSE') + " " + signalquelle.get('SIGNALQUELLE_HSNRVON'); $.signalquelleInformation_plz.text = signalquelle.get('SIGNALQUELLE_PLZ') + " " + signalquelle.get('SIGNALQUELLE_ORT'); $.signalquelleInformation_war.text = signalquelle.get('WAR_PAUSCHALE'); $.signalquelleInformation_kopfstelle.text = signalquelle.get('KOPFSTELLEN_ID'); $.signalquelleInformation_signalqnr.text = signalquelle.get('SIGNALQUELLE_NR'); }after switching out and back to the View i get the following exception. right were $liegenschaften_list.data = rows; is called.
[ERROR] : TiApplication: (main) [18001,27570] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 3.5.1,2015/03/05 10:08,96875c9 [ERROR] : TiApplication: java.lang.NullPointerException [ERROR] : TiApplication: at android.view.ViewConfiguration.get(ViewConfiguration.java:318) [ERROR] : TiApplication: at android.view.View.<init>(View.java:3264) [ERROR] : TiApplication: at android.view.ViewGroup.<init>(ViewGroup.java:448) [ERROR] : TiApplication: at android.widget.FrameLayout.<init>(FrameLayout.java:93) [ERROR] : TiApplication: at ti.modules.titanium.ui.widget.tableview.TiTableView.<init>(TiTableView.java:274) [ERROR] : TiApplication: at ti.modules.titanium.ui.widget.TiUITableView.processProperties(TiUITableView.java:107) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1209) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:500) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:491) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:469) [ERROR] : TiApplication: at ti.modules.titanium.ui.TableViewProxy.getTableView(TableViewProxy.java:150) [ERROR] : TiApplication: at ti.modules.titanium.ui.TableViewProxy.handleSetData(TableViewProxy.java:695) [ERROR] : TiApplication: at ti.modules.titanium.ui.TableViewProxy.handleMessage(TableViewProxy.java:872) [ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:95) [ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:137) [ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5103) [ERROR] : TiApplication: at java.lang.reflect.Method.invokeNative(Native Method) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:525) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) [ERROR] : TiApplication: at dalvik.system.NativeStart.main(Native Method)Things i already tried:
1) instead of writing data directly using setData(rows) same problem
2) having always something in the Tableview i.e. Dummy values and then overwriting the data same problem.
Maybe someone knows what the problem is.. I tried almost everthing releated to this problem when trieing to fix this problem, which is already mentioned here in the forum...
im using 3.5.1 GA and this problem occures on Android (4.3) and IOS (8.3)