VOOZH about

URL: https://qiita.com/softbase/items/94984fa7821ecbc02f5b

⇱ Java でコールバックの簡単サンプル #Android - Qiita


👁 Image
5

Go to list of users who liked

3

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 5 years have passed since last update.

@softbase(FullStack ITエンジニア)

Java でコールバックの簡単サンプル

5
Last updated at Posted at 2019-04-02

interface Callback{
 void call();
}

class A implements Callback{
 private B b;

 public A(){
 b = new B();
 b.registerCallback(this);
 } 

 // Implementation of the callback interface
 public void call(){

 }
}

public class B
{
 private Callback callbackoNotify;

 public class registerCallback(Callback callback)
 {
 callbackoNotify = callback;
 }

 public void doTask()
 { 
 //do some stuff...
 callbackNotify.call();
 }
}
5

Go to list of users who liked

3
2

Go to list of comments

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5

Go to list of users who liked

3