Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.1.4中http://hukai.me/android-training-course-in-chinese/basics/firstapp/starting-activity.html #383

Open
lixuwork opened this issue Mar 4, 2016 · 1 comment

Comments

@lixuwork
Copy link

lixuwork commented Mar 4, 2016

我是新手,刚接触android,还不明白为什么,但是,教程中要删除setContentView(R.layout.activity_display_message);是会出错的。实验了下,不缺掉没问题。马上去查下这个方法的作用……

@LongfeiYang
Copy link

这个方法(setContentView())是为Activity设置View的.每一个活动页面都会有一个视图,就是你在手机上看到的页面。而视图,可以通过两种方式进行添加,分别是Layout文件和Java代码。你看它的下面不是实例化了一个TextView作为这个Activity的视图设置上去了么。不删除自然没问题,等于设置了两次视图,系统显示最后设置的,即TextView。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants