开发者

Android Anonymous Delegate

开发者 https://www.devze.com 2023-01-02 12:32 出处:网络
Coming from a .NET C# background, new to Java开发者_JAVA技巧.... How do I re-write this code to point the listener to a normal function?

Coming from a .NET C# background, new to Java开发者_JAVA技巧....

How do I re-write this code to point the listener to a normal function?

confirmButton.setOnClickListener(new View.OnClickListener() {
     public void onClick(View view) {
    //Some Code Here;
     }
});


Java follows a different concept than C#, it uses 'Anonymous Classes' for this approach. Maybe you should check out Java docs for it.

It is like implement a interface on the fly by a anonymous class.

0

精彩评论

暂无评论...
验证码 换一张
取 消