在选项卡视图中插入图库时出现 nullpointerException
您好,我目前在我的应用程序中创建了一个选项卡视图。这些选项卡工作正常,直到我开始在其中一个选项卡中创建一个图库。有人可以帮我看看吗?在 logcat 中,空指针异常似乎在线 - photos.setAdapter(new GalleryAdapter());
任何帮助将不胜感激..
Hi i have currently created a tab view in my app.. The tabs worked fine until i begin to create a gallery within one of them. Could someone please have a look for me.. In the logcat the nullpointer exception seems to be on line - photos.setAdapter(new GalleryAdapter());
Any help would be greatly appreciated..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想引用图库,则必须调用 setContentView(R.layout.listedsites) 或将其膨胀...到目前为止,您的 Activity 视图层次结构中没有任何内容,因此
((Gallery)findViewById(R.id.gallery) ));
返回 null。另外,在我看来,您只需要“图库”选项卡中的图库,因此在相应的活动中执行您的图库逻辑。
If you want to reference gallery you either have to call setContentView(R.layout.listedsites) or inflate it...as of now nothing is in your Activity view hierarchy so
((Gallery)findViewById(R.id.gallery));
returns null.Also, it seems to me you only want the gallery in your "gallery" tab so do your gallery logic in the corresponding activity.