android - Reason for NullPointerException if setContentView() is not used -


i know need place setcontentview() in oncreate() method before initializing view otherwise throw null pointer exception. reason it?is setcontentview() similar inflate() method?

before initializing view

i not know mean "initializing view". given rest of question, going interpret meaning "call findviewbyid() on activity".

you need call setcontentview() before calling findviewbyid(), because otherwise there no widgets find.

is setcontentview() similar inflate() method?

setcontentview() use layoutinflater , inflate() under covers, if pass layout resource id setcontentview() method.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -