Android Question Move a view @runtime and save new position?

Beja

Expert
Licensed User
Longtime User
Is it possible?
Like when longpress on an icon and then move it to a new position on the screen. I want to do
the same in b4a, but for views not icons (panel, button, checkbox.. etc.)

Thanks in advance for any useful hint.
 

Beja

Expert
Licensed User
Longtime User
Thanks thedesolatesoul,

how can I save the new xy without using a database?
I did this in vb but had to use database to save the last xy, then loaded them in form1.activate

Thanks in advance.
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
So you want to save the state on activity pause?
if there only a few views, you can store them in a text file with a tag.
however if there are like 100s of views, this will be the equivalent of try to create a bal file in text!
if there is only one or two, you can save them in preferencesmanager.
Btw...im not sure if you have seen Erel's statemanager class, you can modify it to save x,y of all the views too.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Thanks again thedesolatesoul,
Have 16 controls, same class they are all check boxes.
will try the text file for saving the state of the views. In VB I was saving the state in (MouseMove) for
each control (real time), so if any thing happened to the system then each control is in it's right location.
 
Upvote 0

SAM ShamsulBahrim

Member
Licensed User
Longtime User
Thanks again thedesolatesoul,
Have 16 controls, same class they are all check boxes.
will try the text file for saving the state of the views. In VB I was saving the state in (MouseMove) for
each control (real time), so if any thing happened to the system then each control is in it's right location.

Hi Beja,

Did you get the runtime-moving-view to work? Can you share the code, please?

SAM
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Hi Sam,
didn't test it in b4a. but I can give you the vb code if you want.. you will need to save the
coordinates in the mouse-up event.
* First right-click the view, and then move the mouse around, you write the routine to make
the view follow the mouse (with both mouse buttons free).
* and then when you reach your destination, right-click the mouse again to drop the view.
* at the mouse-up of this second click is when the (current) coordinates are saved, wherever
you wan to save them.
In activity-create (if first time) you assign the saved coordinates to the x,y of the view.

Cheers!
 
Upvote 0

eps

Expert
Licensed User
Longtime User
If there's only 1 View you could save it in a file, then just re-read. Even if there are lots of Views, depending on your Naming convention you may well be able to use a number of files, this is effectively what StateManager does anyway.
 
Upvote 0
Top