【Android开发】Activity和View的联系和区别

          上周面试阿里的客户端开发岗位, 终面的时候,部门老大问过这样一个问题:Acitivty的直接父类是什么,它有没有直接或者间接地继承View?

          先看看google官方文档中关于Acitivity的描述,

    An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI with setContentView(View).

    再看关于View的描述,

    This class represents the basic building block for user interface components. A View occupies a rectangular area on the screen and is responsible for drawing and event handling. View is the base class for widgets, which are used to create interactive UI components (buttons, text fields, etc.)

    简言之,Activity是一个单独的、聚焦的和用户直接进行交互的组件,这个组件是View的容器,View控件只有放置在这个容器里面才有意义。在MVC的设计模式里面,Activity是Control,负责与用户交互的业务逻辑,而View控件则是将这些业务逻辑显示在屏幕上。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值