Android的Activity类中实现的哪个方法不是模板方法?

huangapple go评论87阅读模式
英文:

Which one method implemented by Android's Activity Class is NOT A Template Method?

问题

A Template Method is a method that you may implement, but you must never call so which one method implemented by Android's Activity Class is NOT A Template Method?

模板方法是一个你可以实现的方法,但绝不能调用的方法,那么Android的Activity类中实现的哪个方法不是模板方法?

英文:

A Template Method is a method that you may implement, but you must never call so which one method implemented by Android's Activity Class is NOT A Template Method?

答案1

得分: 2

我可能没有正确理解问题,但我猜你在谈论生命周期方法:

  • onCreate()
  • onStart()
  • onRestart()
  • onResume()
  • onPause()
  • onStop()
  • onDestroy()

由于它们都可以被实现,但不应该被应用程序的代码直接调用。Activity 的每个其他方法都不是 "模板"(例如 findViewByIdgetContext)。

Activity 类的官方文档

英文:

I probably did not understand the question correctly, however I guess you are talking about lifecycle's methods:

  • onCreate()
  • onStart()
  • onRestart()
  • onResume()
  • onPause()
  • onStop()
  • onDestroy()

Since they all can be implemented but should never be directly called by application's code. Every other method of Activity is not "template" (e.g. findViewById or getContext).

Official documentation for Activity class

huangapple
  • 本文由 发表于 2020年7月28日 18:45:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/63132304.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定