B4ASnippetButton
adding Material icons to button text
The MaterialIcons font is handy for creating icon-only buttons. You can do this right in the Designer. If, however, you want to add an icon to some existing button text (say, a "Save" button with a checkmark before the "Save" text), you can''t do this directly in the Designer because the Material font only offers uppercase letters. So here''s a subroutine that takes any existing button with any existing text (e.g. "Save") and prefixes it with a Material icon. It uses CSBuilder to build a CharSequence containing both parts, then assigns that as the button''s new text.
@Dave O · 2018-11-04
B4ASnippetB4A
Super-others: my 42 common usage subs
Common subs are usually placed into a code module. I decided to check all my projects that have "others.bas" code module, and i have found... 185 unique files. And much more common subs, but 42 pcs of them can be useful for community. Mostly the names are self-explaning, most are from the forum.
@peacemaker · 2018-10-22
B4ASnippetCharSequence / CSBuilder
Save and load CSBuilders
Using this class you can build CharSequences (the output of CSBuilder) and save the information required to build those styled strings. This allows to later load the information and create the same CharSequences.
@Erel · 2018-10-15
B4ASnippetCharts
Predetermined graphs
I wanted a simple graphing function where I could define the range and intervals to sensible values but still have the luxury of the code determining the best fit from some derived values. As long as the maximum X and Y values was less than the maximum predetermined X and Y ranges then the code selects the best fit graph outline. This is easy if say you are measuring a sensor and know the maximum range for argument sake The code will select the best fit range and the predetermined intervals for that range, draw the graph outline and automatically label the X and Y intervals. The graph size is user set, but reduced sizes will require alteration of the interval label sizes to stop clutter An example of Multiple straight line point to point traces is provided
@rodmcm · 2018-10-14
B4ASnippetFile handling
Concept for VERY fast temporary IO
I briefly tested an idea that we can create a ramdisk from the actual very fast RAM, which from memory is normally closer to 900+mb/s On this disk, one could do any normal IO functions such read/write files (ie after creating it the code is basically unchanged), or even move an SQL dB, onto the disk and have pretty darn fast responses
@JohnK · 2018-10-10
B4ASnippetSlider [NO WRAP][B4A]
FluidSlider [No Wrap] [B4A]
(B4A)FluidSlider [No Wrap]
@Star-Dust · 2018-10-10
B4ASnippetMaths
MapRange A-B to C-D
SubName: Map a range of numbers from A-B to C-D and return the mapped value. Description: I use B4R a lot and that package includes a function called MapRange, I couldn''t find a version of MapRange in B4A or anywhere on the forum, so I found the formula online and I put together this little sub. Using MapRange you can map any range of number to another different range of numbers. For example 0 to 100 can be mapped to -50 to 50, 25 to 75, 2000 to 5000, -300 to -150 or whatever number range you need to return a value from. Your original number range can be any range you wish and not just 0 to 100 like above.
@Peter Simpson · 2018-10-03
B4ASnippetList- and scrollview
Header with parallax effect for ULV
This is an example for UltimateListView showing how to create a sticky header (a header that is always visible) with a parallax effect (the image at the top is reduced as the list scrolls and stays centered). The header transparency changes over time so that the background is fully opaque when the image is no longer visible.
@Informatix · 2018-10-02
B4ASnippetRandomise
Get Random Numbers in a non repeating list
Get Random Numbers in a non repeating list
@Myron · 2018-09-30
B4ASnippetB4A
Set any activity orientation (opposite to #SupportedOrientations)
SubName: Set any activity to the opposite orientation used in the app. Description: Using this line of code in your manifest allows you to set one (or more) of your projects activities to a different orientation than the default one which is set in the Main activity using #SupportedOrientations.
@Peter Simpson · 2018-09-20
B4ASnippetOS
Memory Usage
Memory Usage
@Robert Valentino · 2018-09-17
B4ASnippetAudio/Video
aLaw/uLaw PCM - compression, decompression - Code Available to all.
aLaw/uLaw PCM - compression, decompression - Code Available to all.
@Jmu5667 · 2018-09-14
B4ASnippetSMS
SMS verification without permission (Android 8+)
SMS verification without permission (Android 8+)
@Semen Matusovskiy · 2018-09-13
B4ASnippetAudio/Video
precise timing beats (Metronome)
Long time I was not able to write a precise metronome (a tool for musicians). Playing the beats with SoundPool and a Timer was not accurate at all, because of the timer. Even playing in a own thread was not really precise. Finally I got now a 100% precise solution with the AudioTrack Library. For this code you also need the Threading and the ByteConverter Lib.
@skrjabin · 2018-09-12
B4ASnippetColour
Change Link Color in View
With below code you can linkable view and convert phone or url or email to link. I only add change link color method in this function
@Pooya1 · 2018-09-10
B4ASnippetDatabase
jRDC2 Add MySql Master / Detail
Code to add a row in a "master" table, and then the "children rows" in a "detail" table
@josejad · 2018-09-05
B4ASnippetSMS
Sending SMS with _SmsSentStatus and _SmsDelivered events
Sending SMS with _SmsSentStatus and _SmsDelivered events
@peacemaker · 2018-09-02
B4ASnippetAudio/Video
Audio Streamer - Amplify Audio Buffer
I recently needed to add an audio amplifier to a new PTT app we have developed. I found this code on the web and through I would share it. https://stackoverflow.com/questions/14485873/audio-change-volume-of-samples-in-byte-array
@Jmu5667 · 2018-08-28
B4ASnippetDrawing
Bezier curve
How to make the bezier curve with B4A? Here is a simple code, you can edit points by tapping and dragging them and the curve will change.
@Star-Dust · 2018-08-24
B4ASnippetMenu
SlidingMenu in more Activities
This is a small example project on how to implement Erel''s advice from here to make it work on more activities in one project.
@Erel · 2018-08-23
B4ASnippetEditText/Textview/TextArea/TextField
BSLabeledEdit - a composite views Label and EditText
Related to thread https://www.b4x.com/android/forum/threads/solved-change-dsfloatlabeledittexts-hint-size.96348/, the need for a simple labeled edit text and learning CustomView, I share to B4A Community my BSLabeledEdit. It consist Panel, Label, and EditText. It reminds me creating composite components in Delphi.
@Xenno · 2018-08-22
B4ASnippetMail
SMTP equal sign and another
if you have sign equal in SMTP you have problem, same thing with form feed etd.
@MarcoRome · 2018-07-25
B4ASnippetService/Receiver
How to determine what started a Service
As far as I can tell, there are three different reasons a service was started: 1.Manually started using StartService 2.Scheduled start using StartServiceAt or StartServiceAtExact 3.Automatically started at boot using #StartAtBoot I recently found myself needing to know why a service was started, so I came up with the snippet below
@Sandman · 2018-07-24
B4ASnippetB4A
Check device is Emulator
Check if device is Emulator
@Pooya1 · 2018-07-22
B4ASnippetProgress/Gauge/Loading
Simple Progress Bar
This is a sample of progress bar I use in my project. It only use B4A Core library and native view. Yes, what you need is only 2 panels to create the progress bar. The reason I create this view is because I don''t like the square corner of default progress bar and I want to customize the colour.
@aeric · 2018-07-20
B4ASnippetComms & Network
Check Internet Connection
Check Internet Connection
@Pooya1 · 2018-07-19
B4ASnippetFirebase
Simple Message (using FirebaseNotifications) + Source Code
This was my first test-App for Firebase Push Notifications and it is a easy way to chat over different topics/groups.
@skrjabin · 2018-06-26
B4ASnippetWebView
Calling subs with webview links and buttons
I like to use the webview as a very individual user interface. You can load the content offline with WebView1.LoadHtml or do online real time changes on the interface with WebView1.LoadUrl. You can use all the HTML, CSS or even JavaScript to draw a nice view and with this code you can interact, if the user presses a link or a button. That way you can easyly create and quickly change a layout in runtime.
@skrjabin · 2018-06-25
B4ASnippetB4A
Reversing Screen Orientation Using JavaObject
If your activity uses either landscape or portrait orientation, and you want to reverse either orientation, this code snippet will enable you to do so.
@ErickAsas · 2018-06-25
B4ASnippetAction Bar, Drawer, etc [B4A][XUI]
Bottom Toolbar [B4A] [XUI]
I am planning to create a B4A and a B4i app with identical UI. I try to look in this forum if anyone has created a bottom toolbar (iOS-styled) for B4A but I just found this thread with no reply. So I created a quick one in B4A.
@aeric · 2018-06-22