I have created the listView. On the list view there is label available on each row. When we click on the label then I am displaying text field on the same row. when I click on any other label in the row, I am hiding the textfield. It is working fine when we do not change any value of the textfield.
But when i just focus on the textfield and click on other label, I am getting the warning as "View: requestLayout() improperly called by android.widget.ListView{234f9d5f VFED.VC. ......ID 0,0-1080,1527} during layout: running second layout pass".
And when I tried to change the text in the textfield and click on another label then App is crashing.
Steps to reproduce : 1. Click on the any label then textField gets visible. 2. Focus on the textField which is visible and type some text. 3. Then if we click on the any other label then application is crashing showing popup as “Unfortunately, Application has stopped".
can we have any work-around for this ?
Titanium CLI version: 3.4.0 Titanium SDK version : 3.4.0.v20140916181713 OS : Android.
index.xml
<Alloy> <Window class="container"> <View top="10dp"> <ListView id="listViewForColleges" defaultItemTemplate="template"> <Templates> <ItemTemplate name="renameTemp"> <TextField bindId="textField" class="textFieldCls"></TextField> <Label bindId="action" class="actionCls" onClick="rename" /> </ItemTemplate> </Templates> <ListSection id="renameSection"/> </ListView> </View> </Window> </Alloy>index.js
var listData = []; var preIndex; //Created listView of 10 items for (var i = 0; i < 10; i++) { var item = { template : 'renameTemp', textField : { value : "EnterText", right : "10%", color : "black", borderColor: "black", borderWidth : "0.5dp", width : "35%", visible : false }, action : { left : "10%", text : "renmaeLabel"+ i } }; listData[i] = item; } //setting data to listview $.renameSection.setItems(listData); //function calling on the click of renameLabel function rename(e) { //clearing the previous index field on the same item click if(preIndex == e.itemIndex){ preIndex = null; } //showing rename text field on the click of label var item = $.renameSection.getItemAt(e.itemIndex); item["textField"].visible = true; $.renameSection.updateItemAt(e.itemIndex, item); //hiding the text field of previous row which is been visible if (preIndex) { var item1 = $.renameSection.getItemAt(preIndex); item1["textField"].visible = false; $.renameSection.updateItemAt(preIndex, item1); } //storing the index of opened rename text field preIndex = e.itemIndex; } $.index.open();Error Logs :
[WARN] : View: requestLayout() improperly called by android.widget.ListView{27e70902 VFED.VC. ......ID 0,0-1080,1527} during layout: running second layout pass [WARN] : EGL_emulation: eglSurfaceAttrib not implemented [WARN] : OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xa34e8d80, error=EGL_SUCCESS [INFO] : APSAnalyticsService: Analytics Service Started [DEBUG] : AndroidRuntime: Shutting down VM [ERROR] : TiApplication: (main) [34589,34589] Sending event: exception on thread: main msg:java.lang.IndexOutOfBoundsException: setSpan (11 ... 11) ends beyond length 9; Titanium 3.4.0,2014/09/25 16:42,b54c467 [ERROR] : TiApplication: java.lang.IndexOutOfBoundsException: setSpan (11 ... 11) ends beyond length 9 [ERROR] : TiApplication: at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1018) [ERROR] : TiApplication: at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:611) [ERROR] : TiApplication: at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:607) [ERROR] : TiApplication: at android.text.Selection.setSelection(Selection.java:76) [ERROR] : TiApplication: at android.text.Selection.setSelection(Selection.java:87) [ERROR] : TiApplication: at android.widget.EditText.setSelection(EditText.java:99) [ERROR] : TiApplication: at ti.modules.titanium.ui.widget.listview.TiListView$ListViewWrapper.onLayout(TiListView.java:161) [ERROR] : TiApplication: at android.view.View.layout(View.java:15596) [ERROR] : TiApplication: at android.view.ViewGroup.layout(ViewGroup.java:4966) [ERROR] : TiApplication: at org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:575) [ERROR] : TiApplication: at android.view.View.layout(View.java:15596) [ERROR] : TiApplication: at android.view.ViewGroup.layout(ViewGroup.java:4966) [ERROR] : TiApplication: at org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:575) [ERROR] : TiApplication: at android.view.View.layout(View.java:15596) [ERROR] : TiApplication: at android.view.ViewGroup.layout(ViewGroup.java:4966) [ERROR] : TiApplication: at org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:575) [ERROR] : TiApplication: at android.view.View.layout(View.java:15596) [ERROR] : TiApplication: at android.view.ViewGroup.layout(ViewGroup.java:4966) [ERROR] : TiApplication: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573) [ERROR] : TiApplication: at android.widget.FrameLayout.onLayout(FrameLayout.java:508) [ERROR] : TiApplication: at android.view.View.layout(View.java:15596) [ERROR] : TiApplication: at android.view.ViewGroup.layout(ViewGroup.java:4966) [ERROR] : TiApplication: at com.android.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:494) [ERROR] : TiApplication: at android.view.View.layout(View.java:15596) [ERROR] : TiApplication: at android.view.ViewGroup.layout(ViewGroup.java:4966) [ERROR] : TiApplication: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573) [ERROR] : TiApplication: at android.widget.FrameLayout.onLayout(FrameLayout.java:508) [ERROR] : TiApplication: at android.view.View.layout(View.java:15596) [ERROR] : TiApplication: at android.view.ViewGroup.layout(ViewGroup.java:4966) [ERROR] : TiApplication: at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2072) [ERROR] : TiApplication: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1829) [ERROR] : TiApplication: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054) [ERROR] : TiApplication: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779) [ERROR] : TiApplication: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) [ERROR] : TiApplication: at android.view.Choreographer.doCallbacks(Choreographer.java:580) [ERROR] : TiApplication: at android.view.Choreographer.doFrame(Choreographer.java:550) [ERROR] : TiApplication: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) [ERROR] : TiApplication: at android.os.Handler.handleCallback(Handler.java:739) [ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:95) [ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:135) [ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5221) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Native Method) [ERROR] : TiApplication: at java.la [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)