Clickable icons (button images) in TableViewRow - best way?

So what is the correct/best way to implement clickable icons that are images (i.e. in my case, 36x36 PNG icons) in a TableViewRow?

I'm currently using Ti.UI.createView, setting its top/left/width/height, its backgroundImage to the PNG file, and adding that view to the TableViewRow.

Unfortunately, I seem to be hitting a weird roadblock that I'm having a hard time chasing… or have spent too much time chasing.. and am wondering if this is the right way?

Every so often (completely random), the app will crash (Force Close) when I display the TableView with the items above. It seems to be directly related to backgroundImage - as once I comment them out, it will display (I verify this by also setting the borderColor and borderWidth to see where it SHOULD have been placed).

I have so far been unable to track down what causes these crashes/FCs - originally thought it was when the Views/images were overlapping - but that is not the case. something to do with displaying the PNG icons as backgroundImage - and I have yet to figure out a pattern.

Any thoughts/ideas? I'm on Android with Ti 1.5.1

1 Answer

  • is there a reason you are not using image views? How many rows are you talking about here?

    — answered 5 years ago by Aaron Saunders
    1 Comment
    • No reason except I based the code off of the KitchenSink code (Table View Layout 2) because, it was very very similar to what I'm trying to implement (TableViewRows with text as well as icons you can click on) - so I assumed that was the correct or best way to do it…

      Should I swap out the Views (specifically being used for the icons) for ImageViews? I was just assuming it was OK since that's how it's done in KitchenSink. What advantages could I get, and if it's better to do it that way, why didn't Appcelerator use that method in the KitchenSink?

      My TableView is dynamic (i.e. user can have as many rows as it defines) - personally, I have about 200 rows in it right now…

      — commented 5 years ago by Takahito Torimoto