• 请不要在回答技术问题时复制粘贴 AI 生成的内容
allencode
V2EX  ›  程序员

Android 关于回调的疑惑?

  •  
  •   allencode · Mar 7, 2016 · 2633 views
    This topic created in 3892 days ago, the information mentioned may be changed or developed.

    Android 中 activity 启动执行的“ onCreate()”等生命周期函数,为什么称之为回调?跟 view 组件的 onClick()回调是一样的吗?

    2 replies  •  2016-03-07 17:02:54 +08:00
    kifile
    kifile
    Mar 7, 2016
    1
    回调函数应该理解为当系统执行到某个步骤时,为了方便用户执行自定义操作,而进行调用的接口。所以其实这两个地方都可以称为回调。

    Activity 中的 onCreate()是属于其生命周期的一部分,系统帮我们做了很多事情,我们必须调用 super.onCreate(),否则系统会崩溃。

    而 view.onClick 则是用户需要自实现的策略,实现与否,怎么实现取决于需求。
    allencode
    allencode
    OP
    Mar 7, 2016
    2
    @kifile 哦,大致明白了,反正都不是我们认为主意识的去调用咯==
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1281 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 21:09 · PVG 05:09 · LAX 13:09 · JFK 16:09
    ♥ Do have faith in what you're doing.