开发者

Question about the android .finish() method

开发者 https://www.devze.com 2023-01-17 16:36 出处:网络
whats the difference between MyActivity.finish() and MyActivty.this.finish()?I see an example where MyA开发者_如何转开发ctivty.this.finish() is called from hitting the OK button on a dialog asking if

whats the difference between MyActivity.finish() and MyActivty.this.finish()? I see an example where MyA开发者_如何转开发ctivty.this.finish() is called from hitting the OK button on a dialog asking if you want to exit the app. isn't the ".this" part redundant?


MyActivity.finish() assumes that finish() is a static method on MyActivity.

MyActivity.this.finish() is calling finish() on the enclosing instance of MyActivity. It's also equivalent to this.finish() or just finish() (assuming it's being called from within MyActivity).

0

精彩评论

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

关注公众号