Android : Android recursively add buttons in RelativeLayout

on Friday, April 3, 2015


I have been searching for all the solutions related to adding buttons dynamically. Though I am able to add the buttons, yet I have a really weird issue, which almost drives me crazy.


Basically, I have a file listing the button positions. For example, each line represents X and Y coordinates.


**


123 456


234 789


**


In my PinActivity, I loaded a background image using TouchImageView and set a RelativeLayout for adding buttons. The ultimate goal is to make the buttons point to the same position relative to the background image when the user zooms in/out or move the image.


I'm able to read the file into an ArrayList and then add the buttons recursively. However, the PROBLEM is that,


If it is the first time loading the PinActivity, I have to click on the screen to make the buttons show up. If I go back to the previous Activity and fire up PinActivity again, the buttons are displayed fine.


Besides, I tried performClick and it didn't help.


Can someone explain what happened here? Thanks a ton!!!!


Or please let me know if there is a better way to achieve such functionality.


0 comments:

Post a Comment