如何在Android中创建自己的侦听器接口?

有人可以帮助我创建用户定义的侦听器接口与一些代码片段吗?
public interface MyListener {
    // you can define any parameter as per your requirement
    public void callback(View view, String result);
}

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) {   
        // do your stuff here
    }
}

public class MyButton {
    MyListener ml;

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

    public void MyLogicToIntimateOthere() {
        ml.callback(this, "success");
    }
}
http://stackoverflow.com/questions/994840/how-to-create-our-own-listener-interface-in-android

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:如何在Android中创建自己的侦听器接口?