android callback interface

February 4, 2015   ·   0 Comments

Screen Shot 2014-11-17 at 9.56.42 AM
public class MyButton {
    public interface MyListener {
      // you can define any parameter as per your requirement
      public void callback(View view, String result);
   }
    MyListener ml;

    // constructor
    MyButton(MyListener ml) {
        this.ml = ml;
    }

    public void MyLogicToIntimateOthere() {
        ml.callback(this, "success");
    }
}
public class MyActivity extends Activity implements MyListener {
   @override        
   public void onCreate(){
        MyButton m = new MyButton(this);
   }

    // method invoke when mybutton will click
    @override
    public void callback(View view, String result) {   
      System.out.println(result);
    }
}
shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Android7

Amazon

adsbygoogle

Recent Posts

Categories

Amazon