添加选项卡时如何测试 TabActivity 扩展类而不遇到异常?
我得到以下跟踪:
java.lang.NullPointerException
at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:277)
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:651)
at android.widget.TabHost.setCurrentTab(TabHost.java:323)
at android.widget.TabHost.addTab(TabHost.java:213)
....
我的代码:
Intent intent = new Intent(getInstrumentation().getTargetContext(), TabbedView.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ActivityInfo info = new ActivityInfo();
Activity father = new Activity();
TabbedView activity = (TabbedView) getInstrumentation().
newActivity(TabbedView.class, getInstrumentation().getTargetContext(), null, null, intent, info,
TabbedView.class.getName(), father, null, null);
TabbedView
从 TabActivity
延伸并内部到 TabbedView.onCreate()
对 的调用TabHost.addTab()
已发出。
有没有人找到解决这个问题的方法?测试 TabActivity
通常是一个问题。
谢谢。
I'm getting the following trace:
java.lang.NullPointerException
at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:277)
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:651)
at android.widget.TabHost.setCurrentTab(TabHost.java:323)
at android.widget.TabHost.addTab(TabHost.java:213)
....
My code:
Intent intent = new Intent(getInstrumentation().getTargetContext(), TabbedView.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ActivityInfo info = new ActivityInfo();
Activity father = new Activity();
TabbedView activity = (TabbedView) getInstrumentation().
newActivity(TabbedView.class, getInstrumentation().getTargetContext(), null, null, intent, info,
TabbedView.class.getName(), father, null, null);
TabbedView
extends from TabActivity
and inner to TabbedView.onCreate()
a call to TabHost.addTab()
is issued.
Has anyone found a way to solve this problem? Testing TabActivity
is usually a problem.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论