Buttons in Codename One form inactive on Android actual device but work under simulator

感情迁移 提交于 2019-12-23 03:35:08

问题


In my Codename One app I have 2 Forms A & B. A Form includes a MapContainer updated every 10 s and a floating button. If the user clicks on the floating button, they can take a picture and then a Dialog is shown and if they choose "OK" the B Form is shown :

new B_Form(theme).show(); // (where theme is the Resources used in A Form). 

This B Form includes buttons to take some action (ie record audio, play the recorded audio, go to Form A). The buttons work in the simulator (although recording is not supported so an error is shown but it is expected), that is the user can click on it.

However on an actual device (Android KitKat) B Form is shown but no action can be taken although the buttons are all enabled. The buttons even don't show their "pressed style" when being pressed, and remain in "unselected state".

The only button that works is the setBackCommand from the Toolbar (ie the left arrow on the upper left corner of the screen).

So it looks like the B Form was not taken into account. Moreover if I swipe my finger on the B Form then A Form is shown and the map is moved. If I removed the MapContainer from the A Form then B Form works as expected on the device.

EDIT

Surprisingly enough if I call a Form C from the side menu bar via the hamburger menu, the buttons on that Form C work seamlessly!

So I get the feeling that the MapContainer is causing me trouble, what can I do to make B Form work as expected ?

Any help appreciated,

Regards,


回答1:


The MapContainer is a peer component, we enabled the new peers on Android which hide some of the complexities of the peer system but might trigger other issues.

This might be a misbehavior of the peer component system, although it's hard for me to understand how to reproduce this. The side menu would work because the side menu is a completely different form without the map container in it.




回答2:


So here is the workaround I found.

Before showing Form B, I removed the MapContainer and revalidated the Form A :

googleMap.remove(); // googleMap is my MapContainer defined somewhere else
this.revalidate();

Although it works I still don't understand why the problem described in the question happens.



来源:https://stackoverflow.com/questions/41695584/buttons-in-codename-one-form-inactive-on-android-actual-device-but-work-under-si

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!