0
我有4个选项卡,其中之一是通知图标。默认情况下使用标签规格设置所有图标。如何更新tabhost android中的特定标签图标?
spec = host.newTabSpec("Tab Four");
spec.setContent(R.id.tab5);
spec.setContent(new Intent(getApplicationContext(), ICNotificationActivity.class));
spec.setIndicator("", getResources().getDrawable(R.drawable.tab_notification_noted));
host.addTab(spec);
经过一段时间后,我必须更新标签4图标与另一个资源文件。如何更新tabhost?有没有更新功能可用,如host.addTab(spec)?
显示java.lang.NullPointerException调用上述方法:尝试调用虚拟方法 '无效android.view.View.setBackgroundResource(INT)' 上的空对象引用。显示此日志错误。 {host =(TabHost)findViewById(R.id.tabHost); host.setup(); host.getTabWidget()。setStripEnabled(false); host.getTabWidget()。setDividerDrawable(R.drawable.border_tab_activity); host.setup(this.getLocalActivityManager());},已经定义了tabhost。 –
@SARATHV我已经给你我的代码,你需要根据你的需要来改变。 –
代码正常工作,谢谢。我在表格中犯了错误,这就是为什么我得到了空指针异常 –