B4A Library [Lib] ScrollView2D

Hello,

Does it need a long explanation ? You can scroll in the two directions.

This lib does not work with Android versions < 2.

v1.01:
I fixed a big bug in the original code.
I added the function SmoothScrollTo.

v1.02:
I restarted from a fresh basis because of the many bugs in the original code. I fixed most of them (now, multitouch events and hardware keys are correctly handled) but a few are left and need more work (sometimes the wrong object get the focus and resizing is not perfectly handled). I noticed by the way that the stock scrollview is bugged and does not set the focus correctly if you move your finger very slowly.
Thanks to Erel, I solved the problem with the B4A documentation.
I added a new function: FullScroll.

v1.03:
I fixed all known bugs (including bugs found in ScrollView & HorizontalScrollView);
I added the scrollbars;
I added three new functions:
- ScrollbarsVisibility
- FadingEdges
- GiveFocusToFirstVisible.

v1.1:
I fixed a problem with events that were not fired if declared in a class;
I added two functions: ScrollingIsFinished and DisableTouchEventInterception.

v1.2:
SV2D appears now as a custom view in the designer with all its properties.

v1.3:
I fixed a bug (SV_2 = SV_1 did not work because the inner panel was declared in the wrong class).

Enjoy,
Fred
 

Attachments

  • ScrollView2D v1.3.zip
    120.5 KB · Views: 5,870
  • Java source - ScrollView2D.zip
    17.6 KB · Views: 1,766
Last edited:

Informatix

Expert
Licensed User
Longtime User
I doubled the Heap Size from 24 to 48. Still same problem with scrolling photo. Also, I should have mentioned that the app doesn't play back audio even though it does on the phone (using theTTS library). Also, I'm now getting a popup titled "Sorry" containing "The application has stopped unexpectedly. Please try again." with 'Force Close' as the only button. Any ideas?

That could be a lot of things, but without a project to test, it's difficult to point you to the right direction.

Regards,
Fred
 

johnaaronrose

Active Member
Licensed User
Longtime User
Problem solved

Photo scrolling now working fine: I had some rogue coding which I've now removed. What is the best method to work out the Heap Size to be used in the emulator for a specific application? Re my previous question: Are there any implications using android16 in B4A in regard to running it on a 2.3.3 Emulator avd or an Android phone running 2.3.3 or earlier version?
PS Should I start a new thread(s) for these questions?
 

Informatix

Expert
Licensed User
Longtime User
Photo scrolling now working fine: I had some rogue coding which I've now removed. What is the best method to work out the Heap Size to be used in the emulator for a specific application? Re my previous question: Are there any implications using android16 in B4A in regard to running it on a 2.3.3 Emulator avd or an Android phone running 2.3.3 or earlier version?
PS Should I start a new thread(s) for these questions?

The emulator is great to test applications with the minimum heap size (16 Mb) so I'd recommend to always set this size for your tests. That ensures your app will work on every device.
I cannot answer to the second question because I don't understand it.
 

johnaaronrose

Active Member
Licensed User
Longtime User
The emulator is great to test applications with the minimum heap size (16 Mb) so I'd recommend to always set this size for your tests. That ensures your app will work on every device.
I cannot answer to the second question because I don't understand it.

I'll try and explain my second question: it was very difficult grammatically.

Currently, I'm using android10 i.e. the Android SDK is for Android 2.3.3. Thus, I've 'Configured Paths' in B4A to use android.jar in the android10 folder. I test on emulator using 2.3.3 avd's with various resolutions (i.e. 320x480 & 480x800). Will my app's .apk run OK on devices with other Android versions: these could be older (e.g. 2.1) or newer (4.0)? If not, would using Android SDK 4.1 allow the .apk to run on all Android devices?
 
Last edited:

Informatix

Expert
Licensed User
Longtime User
I'll try and explain my second question: it was very difficult grammatically.

Currently, I'm using android10 i.e. the Android SDK is for Android 2.3.3. Thus, I've 'Configured Paths' in B4A to use android.jar in the android10 folder. I test on emulator using 2.3.3 avd's with various resolutions (i.e. 320x480 & 480x800). Will my app's .apk run OK on devices with other Android versions: these could be older (e.g. 2.1) or newer (4.0)? If not, would using Android SDK 4.1 allow the .apk to run on all Android devices?

The best way to know that is to test your app with different OS versions in the emulator.
 

Espinosa4

Active Member
Licensed User
Longtime User
After the application was minimized the program return an error

Hello everybody!
Firstly thank you very much indeed for this lib. It is great.

I'd like to comment a problem that I have. When I minimize the application and the image is still on the screen, passed some minutes, when I return to the application show me this error

Can you help me please?

Capture link

http://db.tt/hYpbdvaI
hYpbdvaI
 
Last edited:

Espinosa4

Active Member
Licensed User
Longtime User
I have no idea. Are you sure it is related to my library? It seems to me that it's because the system wiped out the memory of your application and your app is unable to recover from this situation.

Thank you very very much for reply. I'll try to study the problem with the memory. I am very lost about this but step by step.

Greetings
 

johnaaronrose

Active Member
Licensed User
Longtime User
Monitoring Scroll Positions

I have a map in a .jpg file: I set the ScrollView2D Background Image to its bitmap. This works OK. I'm able to scroll the map both horizontally & vertically. I need to be able to 'get' the Horizontal & Vertical Scroll Positions when the map is is scrolled. However, there seems to be no event associated with this ScrollView2D, which I need in order to store the new Scroll Positions. Am I missing something obvious?
 

Informatix

Expert
Licensed User
Longtime User
I have a map in a .jpg file: I set the ScrollView2D Background Image to its bitmap. This works OK. I'm able to scroll the map both horizontally & vertically. I need to be able to 'get' the Horizontal & Vertical Scroll Positions when the map is is scrolled. However, there seems to be no event associated with this ScrollView2D, which I need in order to store the new Scroll Positions. Am I missing something obvious?

In the IDE, enter Sub + Space + Tab and the event list will appear. SV2D has an event called ScrollChanged.
 

johnaaronrose

Active Member
Licensed User
Longtime User
ScrollChanged event

Unfortunately, (in the IDE) entering Sub + Space + Tab only makes the event list appear for a split second before disappearing. I've tried:
"Sub sv2dMap.ScrollChanged",
"Sub sv2dMap_ScrollChanged",
"Sub sv2dMap.ScrollChanged(PosX as int, PosY as Int)",
"Sub sv2dMap_ScrollChanged(PosX As Int, PosY As Int)".
The latter 2 give compile errors: sort of expected this because it seems to me that the HorizontalScrollPosition should be equivalent to PosX & the VerticalScrolllPosition property should be equivalent to PosY. The former 2 do not cause the Sub to be entered when scrolling is done at runtime: I know this because I've put a MsgBox command in the Sub.

PS I've looked at the documentation for Scrollview2D & there's no mention of the ScrollChange event in it that I see.
 

Informatix

Expert
Licensed User
Longtime User
Unfortunately, (in the IDE) entering Sub + Space + Tab only makes the event list appear for a split second before disappearing.
You have a problem with your IDE then, because this list is not supposed to disappear.

"Sub sv2dMap_ScrollChanged(PosX As Int, PosY As Int)"
This one is correct.
This event is used in the example that you'll find with the library (since the first version).

You can rename the parameters in the event declaration if you prefer to call PosX "HorizontalPosition".
 

johnaaronrose

Active Member
Licensed User
Longtime User
Sv2DExample ignores sv2d_scrollchanged sub

I run B4A under Wine using Ubuntu on my desktop, as I do not use Windows. This has a problem with compiling to my Android phone (probably due to Wine) whether I use USB cable, wireless or Bluetooth i.e. it does not find the device when compiling. So I compile & then copy the .apk (from my desktop) to the phone's sdcard by connection with a USB cable & allowing file copying using usb under GingerBread. I then install the app from the sdcard. I can see the Log using the Android CatLog app (downloaded from Google Play Store & works well). After installing & running Sv2DExample_Debug, CatLog shows "B4A W ignoring event sv2d_scrollchanged" and there is no display of PosX & PosY.
PS I'm now running ScrollView2D v 1.10 (previously running 1.03) & have reloaded it in my app without making a difference.
 
Last edited:

Informatix

Expert
Licensed User
Longtime User
After installing & running Sv2DExample_Debug, CatLog shows "B4A W ignoring event sv2d_scrollchanged" and there is no display of PosX & PosY.

The message "ignoring event" is only sent to the log (by B4A) when the activity is paused (the event is ignored for this good reason).

Did you run my example code unmodified? If yes, then the only culprit that I see here is Wine or CatLog, because ScrollView2D raises its events with the same function as all other B4A views with events. There's nothing particular about it.

Try also the Klaus's example. The output is redirected to the activity title.
 

johnaaronrose

Active Member
Licensed User
Longtime User
The message "ignoring event" is only sent to the log (by B4A) when the activity is paused (the event is ignored for this good reason).

Did you run my example code unmodified? If yes, then the only culprit that I see here is Wine or CatLog, because ScrollView2D raises its events with the same function as all other B4A views with events. There's nothing particular about it.

Try also the Klaus's example. The output is redirected to the activity title.

I copied the .apk file generated by compiling the project containing your unmodified Sv2DExample.b4a. Interestingly, I amended Klaus's SQLiteDB by adding
Msgbox("Posx="&PosX&",PosY="&PosY, "scvList_ScrollChanged")
immediately after Sub scvList_ScrollChanged(PosX, PosY)
and it displayed the Msgbox at runtime. I've just amended it by adding the same line after the Sub line to Sv2DExample and that now displays the Msgbox.

So it looks like CatLog is misbehaving. I think that the problems might be due to having only 353MB space on the sdcard & *perhaps more importantly) 44MB space on internal storage. Is that reasonable?
 
Top