0

My class extends Manager and calls setPositionChild(Field f) to change f's position. After calling setPositionChild() method, how do I apply the position(i.e. re-layout and re-paint) so I can see the changes?

I tried to call invalidate(), which did not work.

draw
  • 4,696
  • 6
  • 31
  • 37
  • **where** are you making those calls? inside which method? – Nate Dec 06 '12 at 04:56
  • @Nate It was called inside the sublayout method. I finally found the solution. I created a class that extends Manager and create a method calling setPositionChild(Field f) and invalidate is enough... – draw Dec 07 '12 at 00:20

1 Answers1

2

invalidate() just forces a repaint, it doesn't redo the whole layout, as you noticed.

You can force a relayout by going up to the parent Screen object, and calling invalidateLayout(). Forcing the layout will almost certainly call setPositionChild() on the field you are trying to move, so you will want to make sure the new field position is preserved by the manager layout code. This may mean you need to write a custom manager.

Michael Donohue
  • 11,776
  • 5
  • 31
  • 44