Creating your custom event listeners in android

preview_player
Показать описание
In this tutorial I will show you how to create your own custom event listeners in android to communicate between classes. To do this, we will be creating an event dispatcher framework in android.
Рекомендации по теме
Комментарии
Автор

Thanks... Nice video. Some tips for your videos. #1. Slow down a little. #2. Slow down a little.

FYI:
The .remove logic in the removeEventListener function in EventDispatcher.java will not work properly if the listenerList has more than 1 item of the same type. You can't use .remove in the loop the way you are doing it. If you remove them starting from the end of the array to the beginning of the array you will be ok. You have to do it this way for it to work correctly.

// A Correct Way Of Removing Items
public void removeEventListener(String type)
{
for (int x = listenerList.size() - 1; x >= 0; x--)
{
Listener listener = listenerList.get(x);

if(listener.getType() == type)
{
listenerList.remove(x);
}
}
}

For those people that noticed that the removeAllEventListeners() function was not finished in the video and wanted to see some code. Here ya go...

public void removeAllEventListeners()
{

}

michaelsarver
Автор

Thank you sir! very comprehensive and going for a well designed solution! Please do continue to make such videos, it is very helpful!

DineshkumarPuli
Автор

Can't understand the english, and video is too sped up

CAPd
Автор

very nice tutorial...
hello sir...
i want to create custom event for the listview. how can i implement?

PradeepKumar
Автор

Greate! One question: if I need: {ANY EVENT FROM SOME ARRAY}, new IEventHandler() {... " ? Can you help me with this ?

vadimmalckin
Автор

How does button click listeners work ?

gssaditya
Автор

how to can i get interface data and store it to sqllite database?

patvill
Автор

Too much difficult procedure for simply teaching the events. It should be done in simple manner.

ziaurrehman