B4A Library ToastMessageShow v2.10

ToastMessageShow
Author:
Giuseppe Salvi
Version: 2.0
 

Attachments

  • ToastMessageShow v1.80.zip
    293 KB · Views: 1,513
  • Normal toast from  xml.png
    Normal toast from xml.png
    24.2 KB · Views: 2,430
  • Normal toast with nine-patch.png
    Normal toast with nine-patch.png
    27.4 KB · Views: 2,347
  • standard toast.png
    standard toast.png
    22.7 KB · Views: 2,167
  • Toast with button and bacckground image.png
    Toast with button and bacckground image.png
    117.4 KB · Views: 2,086
  • Toast with button background color and text shadow.png
    Toast with button background color and text shadow.png
    42.2 KB · Views: 2,083
  • Toast with buttton and resources nine-patch.png
    Toast with buttton and resources nine-patch.png
    81.7 KB · Views: 2,068
  • Toast with buttton and with background resources.png
    Toast with buttton and with background resources.png
    77.8 KB · Views: 2,139
  • Toast with buttton gradient and custom font.png
    Toast with buttton gradient and custom font.png
    190.4 KB · Views: 2,119
  • ToastMessageShowv2.10.zip
    50.2 KB · Views: 1,334
Last edited:

pesquera

Active Member
Licensed User
Longtime User
good job! thank you so much
just a question.. I'm try without luck to catch an event when the user do a click on the message (long delay)
myToast.Initialize("Toast")
Sub myToast_Click
do something
end sub
How should I do? Is it possible to do?
thanks!
 

lonleystar

Well-Known Member
Licensed User
Longtime User
hi pesquera, u can catch the events in a string and give the string to the toast.

P.S.

U can use the seconds instead long delay example:

[ ToastDuration = 6 ]
it'll display the toast 6 seconds.


If i understood good please let me know otherwise make an examples and i'll try it.
 
Last edited:

pesquera

Active Member
Licensed User
Longtime User
hi Lonleystar, thanks for your reply..
I'm a bit confused.. to display 6 seconds doesn't should be ToastDuration=6000?
What I'm trying to do is assign a big ToastDuration time, let's say 10 seconds.. but, I want that the user can close it doing a click on the message
I thought that clicking on the message fires an event (click event)
Sub myToast_Click
do something
end sub
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Ciao Giuseppe.

Non ho provato la libreria ma se posso dare un consiglio, io aggiungerei, se non è troppo complicato, un metodo per interrompere la visualizzazione del messaggio. Cioè, magari la imposti per 5 secondi ma poi vuoi interromperla prima dello scadere.

Ad esempio, io ho una lista che, appena caricata di dati, questi possono "lanciare" alcuni messaggi toast in sequenza; se l'utente esce dall'activity, tutta la coda di messaggi dovrebbe terminare.

Provo a tradurre, in maniera più sintetica ;).
_______________________________________

Synthetic translation:

It would be a useful method to cancel a message before the display time has expired.
 

LucaMs

Expert
Licensed User
Longtime User
With regard to:

hi pesquera, u can catch the events in a string and give the string to the toast.

P.S.

U can use the seconds instead long delay example:
[ ToastDuration = 6 ] it'll display the toast 6 seconds.


If i understood good please let me know otherwise make an examples and i'll try it.


I downloaded your example (I could not run it because I own the previous version of B4A, but I used the code of Activity).

In the initialization code:
B4X:
Toast.ToastDuration =5000' toast.TOAST_LONG_DELAY

So the time is expressed in milliseconds (it should be specified in the description).

When I press 2 or more buttons in a row, I get the display of the first message and not the next.

Instead, if I use:
B4X:
Sub btnShowToastMsg_Click
    Toast.ToastShow("Hello")
    Toast.ToastShow("Bye bye")
End Sub

only the second one will be displayed.

The original Toast manages a message queue, as this last code would show both messages (unfortunately, using the original, I do not have the capability to terminate a message or the whole queue).

Finally, I have not figured out how to use the event (if there is one).
Normally, the text written in the initialization is the name of an event, but it is partial. That is:
B4X:
Dim btn as Button
btn.Initialize("MyButton")

sub MyButton_Click
...

but for a different object (view), I could have a greater number of events, for example MyButton_DoubleClick.

In short, MyButton is not actually the name of the event; what is the full name of the event if I initialize:
B4X:
Toast.Initialize("MyToast")
sub MyToast_???

(Personally, I would rename the method "ToastShow" as "Show")
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Thanks for your reply.

I don't need events, but I did not understand the answer to this question ;)

(i think the Toasts don't need events).

As I wrote (in italian, Giuseppe Salvi!?), I have a list of data in a scrollview. Each of them could "send" a toast, when loaded (i don't like it, probably I'll change all this behavior); using the original Toast, messages are displayed sequentially, and this is the right behavior, but Toasts still on screen even if the user changes activity, and this is not useful.

For this reason, I counseled you to add a method to "close" the message (you have done this quickly, great job) but what is missing is the queue.

Very nice library.
 

pesquera

Active Member
Licensed User
Longtime User
Hi All, thank you.. it's very useful to stop toast when closing the activity
Now, I need also to stop it when the user press (click) on the toast message.. How can I do it?
 

Kapelis

Member
Licensed User
Longtime User
I solved it, I did not understand what happened but I changed the name of the file "info.png" and now everything is ok. Thank you so much Lonleystar for this library!

I have inserted your library to my project but i can't compile it anymore, i get this error:
B4X:
Parsing code.                          0.07
Compiling code.                        0.07
  
ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code.                0.00
Generating R file.                      0.10
Compiling generated Java code.          1.90
Convert byte code - optimized dex.      1.11
Packaging files.                        1.42
Copying libraries resources            0.06
    Found 12 resource files.
Signing package file (private key)      Error

jarsigner: unable to sign jar: java.util.zip.ZipException: duplicate entry: assets/info.png
Any help please?
 
Last edited:

Jaames

Active Member
Licensed User
Longtime User
Thanks for the lib, good job!

But, on the device with android 2.3.7 it throws a error message:


java.lang.NoSuchMethodError: android.widget.TextView.setPaddingRelative.
 

lonleystar

Well-Known Member
Licensed User
Longtime User
I solved it, I did not understand what happened but I changed the name of the file "info.png" and now everything is ok. Thank you so much Lonleystar for this library!

I have inserted your library to my project but i can't compile it anymore, i get this error:
B4X:
Parsing code.                          0.07
Compiling code.                        0.07
 
ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code.                0.00
Generating R file.                      0.10
Compiling generated Java code.          1.90
Convert byte code - optimized dex.      1.11
Packaging files.                        1.42
Copying libraries resources            0.06
    Found 12 resource files.
Signing package file (private key)      Error

jarsigner: unable to sign jar: java.util.zip.ZipException: duplicate entry: assets/info.png
Any help please?



Hi, U get this error because U put an icon with the same name in your assets folder it is alreadi included in to the lib. that's why U get this error.

P.S.
I'll change it.
 
Top