java 导入 android.view.View 的意义
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33302030/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Meaning of Import android.view.View
提问by Manuty
I have been following tutorials on how to make apps and I want to make a GUI purely in java in AndroidStudio. The am confused as to what packages are to be imported. Specifically, what does the following code mean?
我一直在关注如何制作应用程序的教程,我想在 AndroidStudio 中完全用 Java 制作 GUI。我对要导入哪些包感到困惑。具体来说,下面的代码是什么意思?
import android.view.View
导入 android.view.View
回答by Not Gabriel
View is a simple rectangle, the building block of applications, as the documentationrefers to it. Every Widget (TextViews, Buttons, and every other UI component) extends this class.
View 是一个简单的矩形,它是应用程序的构建块,正如文档中提到的那样。每个小部件(TextViews、Buttons 和所有其他 UI 组件)都扩展了这个类。
Show us your code and we can tell you why you need this class, but seriously, for this kind of question, just use the documentation.
向我们展示您的代码,我们可以告诉您为什么需要这个类,但严肃地说,对于此类问题,只需使用文档。
Ask for help if you don't know how to use the docs.
如果您不知道如何使用文档,请寻求帮助。
回答by bitbybit
Views (and ViewGroups) are the basic building blocks of the Android UI. I believe you should go through this introductory training articlefirst to get familiar with the concept and its use.
视图(和视图组)是 Android UI 的基本构建块。我相信您应该先阅读这篇介绍性培训文章,以熟悉该概念及其用法。
The graphical user interface for an Android app is built using a hierarchy of View and ViewGroup objects. View objects are usually UI widgets such as buttons or text fields. ViewGroup objects are invisible view containers that define how the child views are laid out, such as in a grid or a vertical list.
Android 应用程序的图形用户界面是使用 View 和 ViewGroup 对象的层次结构构建的。视图对象通常是 UI 小部件,例如按钮或文本字段。ViewGroup 对象是不可见的视图容器,用于定义子视图的布局方式,例如在网格或垂直列表中。

