Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-25503

Android: can not use a CardView inside an ItemTemplate

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Release 7.3.0
    • Component/s: None
    • Labels:
    • Environment:
    • Story Points:
      5
    • Sprint:
      2018 Sprint 10 SDK

      Description

      As title says, I am trying to create an ItemTemplate which has a CardView inside it, but this causes the app to crash. This is the error showing in Appcelerator's console:

      [ERROR] :  TiApplication: (main) [49049,49384] Sending event: exception on thread: main msg:java.lang.IllegalArgumentException: Cannot add a null child view to a ViewGroup; Titanium 6.3.0,2017/10/31 18:13,undefined
      [ERROR] :  TiApplication: java.lang.IllegalArgumentException: Cannot add a null child view to a ViewGroup
      [ERROR] :  TiApplication: 	at android.view.ViewGroup.addView(ViewGroup.java:4250)
      [ERROR] :  TiApplication: 	at android.view.ViewGroup.addView(ViewGroup.java:4230)
      [ERROR] :  TiApplication: 	at ti.modules.titanium.ui.widget.listview.ListSectionProxy.generateChildContentViews(ListSectionProxy.java:731)
      [ERROR] :  TiApplication: 	at ti.modules.titanium.ui.widget.listview.ListSectionProxy.generateCellContent(ListSectionProxy.java:703)
      [ERROR] :  TiApplication: 	at ti.modules.titanium.ui.widget.listview.TiListView$TiBaseAdapter.getView(TiListView.java:284)
      [ERROR] :  TiApplication: 	at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220)
      [ERROR] :  TiApplication: 	at android.widget.AbsListView.obtainView(AbsListView.java:2363)
      [ERROR] :  TiApplication: 	at android.widget.ListView.makeAndAddView(ListView.java:1970)
      [ERROR] :  TiApplication: 	at android.widget.ListView.fillDown(ListView.java:704)
      [ERROR] :  TiApplication: 	at android.widget.ListView.fillSpecific(ListView.java:1412)
      [ERROR] :  TiApplication: 	at android.widget.ListView.layoutChildren(ListView.java:1708)
      [ERROR] :  TiApplication: 	at android.widget.AbsListView.onLayout(AbsListView.java:2162)
      [ERROR] :  TiApplication: 	at android.view.View.layout(View.java:17637)
      [ERROR] :  TiApplication: 	at android.view.ViewGroup.layout(ViewGroup.java:5575)
      [ERROR] :  TiApplication: 	at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:610)
      [ERROR] :  TiApplication: 	at ti.modules.titanium.ui.widget.listview.TiListView$ListViewWrapper.onLayout(TiListView.java:153)
      [ERROR] :  TiApplication: 	at android.view.View.layout(View.java:17637)
      [ERROR] :  TiApplication: 	at android.view.ViewGroup.layout(ViewGroup.java:5575)
      [ERROR] :  TiApplication: 	at org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:862)
      [ERROR] :  TiApplication: 	at android.view.View.layout(View.java:17637)
      [ERROR] :  TiApplication: 	at android.view.ViewGroup.layout(ViewGroup.java:5575)
      [ERROR] :  TiApplication: 	at org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:862)
      [ERROR] :  TiApplication: 	at android.view.View.layout(View.java:17637)
      [ERROR] :  TiApplication: 	at android.view.ViewGroup.layout(ViewGroup.java:5575)
      [ERROR] :  TiApplication: 	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
      [ERROR] :  TiApplication: 	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
      [ERROR] :  TiApplication: 	at android.view.View.layout(View.java:17637)
      [ERROR] :  TiApplication: 	at android.view.ViewGroup.layout(ViewGroup.java:5575)
      [ERROR] :  TiApplication: 	at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:443)
      [ERROR] :  TiApplication: 	at android.view.View.layout(View.java:17637)
      [ERROR] :  TiApplication: 	at android.view.ViewGroup.layout(ViewGroup.java:5575)
      [ERROR] :  TiApplication: 	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
      [ERROR] :  TiApplication: 	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
      [ERROR] :  TiApplication: 	at android.view.View.layout(View.java:17637)
      [ERROR] :  TiApplication: 	at android.view.ViewGroup.layout(ViewGroup.java:5575)
      [ERROR] :  TiApplication: 	at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
      [ERROR] :  TiApplication: 	at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
      [ERROR] :  TiApplication: 	at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
      [ERROR] :  TiApplication: 	at android.view.View.layout(View.java:17637)
      [ERROR] :  TiApplication: 	at android.view.ViewGroup.layout(ViewGroup.java:5575)
      [ERROR] :  TiApplication: 	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
      [ERROR] :  TiApplication: 	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
      [ERROR] :  TiApplication: 	at com.android.internal.policy.DecorView.onLayout(DecorView.java:726)
      [ERROR] :  TiApplication: 	at android.view.View.layout(View.java:17637)
      [ERROR] :  TiApplication: 	at android.view.ViewGroup.layout(ViewGroup.java:5575)
      [ERROR] :  TiApplication: 	at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2346)
      [ERROR] :  TiApplication: 	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2068)
      [ERROR] :  TiApplication: 	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
      [ERROR] :  TiApplication: 	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6337)
      [ERROR] :  TiApplication: 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
      [ERROR] :  TiApplication: 	at android.view.Choreographer.doCallbacks(Choreographer.java:686)
      [ERROR] :  TiApplication: 	at android.view.Choreographer.doFrame(Choreographer.java:621)
      [ERROR] :  TiApplication: 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
      [ERROR] :  TiApplication: 	at android.os.Handler.handleCallback(Handler.java:751)
      [ERROR] :  TiApplication: 	at android.os.Handler.dispatchMessage(Handler.java:95)
      [ERROR] :  TiApplication: 	at android.os.Looper.loop(Looper.java:154)
      [ERROR] :  TiApplication: 	at android.app.ActivityThread.main(ActivityThread.java:6119)
      [ERROR] :  TiApplication: 	at java.lang.reflect.Method.invoke(Native Method)
      [ERROR] :  TiApplication: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
      [ERROR] :  TiApplication: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
      

      And this is my code (xml, tss, js):

      xml:

      <ListView id="list" defaultItemTemplate="temp">
        <Templates>
          <ItemTemplate name="temp" >
            <CardView id="cardData" >
      	<View class="views" >
      	  <Label left="8dp" color="#212121" bindId="name" />
      	  <ImageView class="icons" right="8dp" image="/icons/more_vert.png" />
      	</View>
            </CardView>
          </ItemTemplate>
         </Templates>
         <ListSection id="section" />
      </ListView>
      

      tss:

      'CardView': {
      	top: "20dp",
      	left: "20dp",
      	right: "20dp",
      	bottom: "20dp",
      	width: Ti.UI.FILL,
      	height: Ti.UI.SIZE,
      	contentPadding: 40,
      	cardCornerRadius: 20,
      	cardUseCompatPadding: true,
      	backgroundColor: "#fafafa",
      	layout: 'vertical'
      }
       
      ".views" : {
      	top: "16dp",
      	layout: "horizontal",
      	height: Ti.UI.SIZE
      }
       
      ".icons" : {
      	width: "24dp",
      	height: "24dp"
      }
      

      js:

      var array = ["aaa", "bbb", "ccc"];
       
      var items = [];
       
      for (var i = 0; i < array.length; i++)
      {
         	items.push({
         		"name" : { text: array[i] },
         		"template" : "temp"
         	});
      }
      $.section.setItems(items);
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gmathews Gary Mathews
                Reporter:
                gfigueras Guillermo Figueras
                Reviewer:
                Yordan Banev
                Tester:
                Samir Mohammed
              • Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-5968
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code