I understand that it has to do with the App layout, but when do I have to use it? I tried to look for a link that explained this method, but I couldn't find it. Thank you in advance!
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
You can set content view (or design) of an activity. For example you can do it like this too :
Also watch this tutorial too.
in Android the visual design is created in xml . And each Activity is associated to a design
R means Resource
layout means design
main is the xml you have created under
res->layout->main.xml
Whenever you want to change your current Look of an Activity or when you move from one Activity to another . The other Activity must have a design to show . So we call this method in onCreate and this is the second statement to set the design
Set the activity content from a layout resource. The resource will be inflated, adding all top-level views to the activity.
As per the documentation :
Your
Launcher
activity in the manifest first gets called and it set the layout view as specified in respective java filessetContentView(R.layout.main);
. Now this activity usessetContentView(R.layout.main)
to set xml layout to that activity which will actually render as the UI of your activity.setContentView(int layoutid) - method of activity class. It shows layout on screen.
R.layout.main - is an integer number implemented in nested layout class of R.java class file.
At run time device will pick up their layout based on the id given in setcontentview() method.
want to know more click on the link
http://androidride.com/what-is-setcontentview-in-android/