Changing View properties after onCreate()
First time poster, new to Android, and I seem to have hit a roadblock on this problem:
I'm creating a dynamic layout, consisting of several identical "composite" objects (these are basically "floating" LinearLayouts, each containing an icon (ImageView) and a caption (TextView)). The (x,y) coordinates of each LinearLayout are subject to change, based on user actions, and require precise placement (ie: can't use RelativeLayout, etc), so I'm positioning them inside an AbsoluteLayout.
During onCreate(), I'm adding each of these objects as a child View inside an AbsoluteLayout object, then setting the (x,y) manually. No problems so far, works great, initial layout is perfect.
The problem:
After the initial onCreate(), I can't get the (x,y) positions of these objects to change on the screen. I can update their layoutParams, but the on-screen layout (inside the AbsoluteLayout) is never refreshed. I've tried forceLayout(), invalidate(), requestLayout(), none of them work.
Is there a problem with my basic approach here, or is there something I'm just missing?
I'm thinking of changing to a SurfaceView and just doing the rendering the hard way, but my code works 99% great right now and I don't want to change it if I don't have to. The only problem is that the layout manager simply refuses t开发者_StackOverflow社区o register the position changes for my child objects.
Help, what am I doing wrong?
Did you try creating a handler for UI and then updating your UI from that..
UI will not be able update from different thread. So, create a thread handler for UI and update the changes to UI using that handler.
-vinay
精彩评论