layout - How to save the position of a dragged ImageView in Android? -


following situation:

i have layout imageviews on it. user can drag them around. have button add new imageviews. when clicking overview can choose image. overview activity ends , return fragment.

now problem:

because fragment initialized again when returning other activity, positions of imageviews put in place before lost.

whats best way save positions of dragged imageviews? margins of each , save them? have sqlite db running think it's overkill save position of each imageview there.

well question app remember positions in case of restart?

if do, need use sort of persistent storage, such database, file or sharedpreferences.

if not, cache them in memory, in hashmap example.

to positions, in ondraglistener:

public boolean ondrag(view v, dragevent event) {      final int action = event.getaction();     switch(action) {          // ...          case dragevent.action_drop:             float x = event.getx;             float y = event.gety;              saveposition(x, y);             break;     } } 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -