How To Implement Callback Method

This example shows how to implement callback method in android.

Algorithm:

1.) Create a new project by File-> New -> Android Project name it CallbackImplementation.

2.) Create and write following into scr/SubClass.java:

 

 

 

3.) Write following into main.xml:

 

 

 

4.) Run for output.

Steps:

1.) Create a project named CallbackImplementation and set the information as stated in the image.

Build Target: Android 4.4
Application Name: CallbackImplementation
Package Name: com.example.CallbackImplementation
Activity Name: CallbackImplementationActivity

callback1

2.) Open CallbackImplementationActivity.java file and write following code there:

 

 

 

3.) Compile and build the project.

Output

callback2

callback3