NullPointerException on findViewById() in android

前端 未结 3 1620
我在风中等你
我在风中等你 2020-12-06 18:35

In the following code i get a NullPointerException on lines 9/10 with findViewById().
In my main class I just instantiated an object from this class, to use .getFrom()

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-06 19:30

    The setContentView method should be called with appropriate layout before calling findViewById. It is usually called in onCreate(Bundle savedInstance) method.

提交回复
热议问题