How to inflate a view in a determined position?

Posted by Tivie on Stack Overflow See other posts from Stack Overflow or by Tivie
Published on 2010-12-30T06:22:28Z Indexed on 2010/12/30 6:54 UTC
Read the original article Hit count: 185

Filed under:
|
|
|

I have an activity with an "Add" and a "Delete" button.

The "Add Button" inflates a view, the "Delete Button" removes a selected View.

When I inflate a view with the "Add Button", it is automatically drawn below any previously infalted view.

I would like to give the user the possibility to move each inflated view up and down, so he could change the order they are show in screen (in a drag'n'drop kind of effect)

+---------------------+     +---------------------+
| +-----------------+ |     | +-----------------+ | 
| |      View 1     | |     | |      View 2     | |  
| +-----------------+ |     | +-----------------+ |
|                     | --> |                     |
| +-----------------+ |     | +-----------------+ |
| |      View 2     | |     | |      View 1     | |
| +-----------------+ |     | +-----------------+ |  
+---------------------+     +---------------------+

Is it possible to specify the "position" in which each view is inflated? (for instance, below or above the currently selected view?)

If not, what is the best way to accomplish the desired effect?

(feel free to ask for any piece of code, if you think it might help)

© Stack Overflow or respective owner

Related posts about android

Related posts about drag-and-drop