Problem running android HelloTabWidget example - NullPointerException on addTab()

后端 未结 12 1169
陌清茗
陌清茗 2021-01-13 17:17

I\'ve tried the Tab Layout example, and I\'ve also fixed the few typos in the example (and added all the activities to the manifest). However, when I run it on the emulator

12条回答
  •  温柔的废话
    2021-01-13 17:55

    I'm only starting programming for the Android, and I encountered this problem, too. I have to say I was quite frustrated with it. Doing what Ngetha suggested helped me out, but I also had to edit my code a little. What I noticed is that apparently the Android does not like sub-classed Activities. At all. I thought I would make my code cleaner by encapsulating everything, but that's apparently not okay. I had to move my classes to separate files. I hope this helps other new programmers with the same encapsulation problem I had.

提交回复
热议问题