Android Question Events that don't trigger

LucaMs

Expert
Licensed User
Longtime User
(It is difficult to write this question simply; I should attach a sample project but it will take me some time to do it. Also, sarebbe ora che tutti voi imparaste l'italiano, così io avrei meno problemi nel porre le domande ? - please, use Google Translator, for this last part) .

In a B4XPage I have a routine that does some work on a Panel (B4XView, of course). In this Panel there is a Button, whose event-routine is obviously located in the B4XPage.

The routine (the main one, not the event one) must remove all views from the Panel and, after some time and work, reloads them. Now I want to "move" this routine to a class (in the future a custom view). To do this, I pass to the routine:

- the Panel (B4XView)
- Me. Callback (the B4XPage)
- [event name]
- Root
- the name of the layout file relating to the content of the Panel, therefore including the Button. As already written, I will have to remove the views from the Panel and then load them again.

Well, with this routine written in the B4XPage the click event of the Button is triggered, while if I "move" it to the class (class declared and initialized in the B4XPage, keeping the Button Click event in the B4XPage, where it is needed), no.

I could think about it a little more, but I know that someone already has in mind what the problem is and how to fix it, so I make my single neuron work less ?
 
Last edited:

klaus

Expert
Licensed User
Longtime User
The event routines must be in the module where you declare and initialize the view !
You can call another routine in the module where you initialize the class and call this routine from the event routine in the class module.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
The event routines must be in the module where you declare and initialize the view !
You can call another routine in the module where you initialize the class and call this routine from the event routine in the class module.
Yes but I can't, because I don't know what views will be inside the panel and so I cannot write event routines in the class, it should be "dynamic".
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I try to explain better.

In the B4XPage I will certainly have a Panel in which I will have N Views. The event-routines must be in the B4XPage.

Then I must be able to pass the Panel to a class which will have to temporarily remove its Views and lately reload them.

?
Here, writing this I came up with the solution (perhaps): when the class has finished its work on the Panel, it will throw an event received by the B4XPage and this will reload the layout.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
?
Here, writing this I came up with the solution (perhaps): when the class has finished its work on the Panel, it will throw an event received by the B4XPage and this will reload the layout.
It works. It will be a nuisance for the programmer who will use the Custom View (i.e. myself) but I will provide the source of the event-procedure as code to copy and paste, in the comment.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
It works. It will be a nuisance for the programmer who will use the Custom View (i.e. myself) but I will provide the source of the event-procedure as code to copy and paste, in the comment.
No, this is not the best solution, because it would also be necessary to resize the TextSize of all the Views there and at this point we might as well do everything in the internal routine of the B4XPages, the class becomes practically useless.

Yet I would need to create a B4Xlib that allows that work on a Panel.

? ? ? ? ? ?
 
Upvote 0
Top