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

events attached to a view not working in Android

    Details

      Description

      {html}<div><p>If you attach a click event to a view with
      addEventListener("click",....), the event does not fire unless
      you've created children objects inside the view.</p>
      <p>Example (this works fine on iOS but not on Android):</p>
      <p>var myView = Ti.UI.createView({<br></p> <pre> <code>top:100, left:100, height:40, width:40, backgroundColor:'red'</code> </pre> <p>});</p>
      <p>win1.add(myView);</p>
      <p>myView.addEventListener("click",function(e) {<br></p> <pre> <code>alert("you tapped the red box!");</code> </pre> <p>});</p>
      <hr>
      <p>However, if you add a label to the view,<br>
      clicking on the label fires the event:</p>
      <hr>
      <p>var myView = Ti.UI.createView({<br></p> <pre> <code>top:100, left:100, height:40, width:40, backgroundColor:'red'</code> </pre> <p>});</p>
      <p>var myLabel = Ti.UI.createLabel({text:"AAA"});<br>
      myView.add(myLabel);</p>
      <p>win1.add(myView);</p>
      <p>myView.addEventListener("click",function(e) {<br></p><pre><code>alert("you tapped the red box!");</code></pre><p>});</p></div>{html}

        Attachments

          Activity

            People

            • Assignee:
              dthorp Don Thorp
              Reporter:
              burggraf Burggraf
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

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

                  Git Integration