Answer the question
In order to leave comments, you need to log in
Why is android.content.res.Resources$NotFoundException: Resource ID #0x0 thrown when trying to set activities as tabs?
I'm trying to set activities as TabHost tabs and I see an exception android.content.res.Resources$NotFoundException: Resource ID #0x0
Android 4.2.2, I'm debugging on the phone.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tabs);
TabHost tabHost = new TabHost(this);
tabHost.setId(android.R.id.tabhost);
TabWidget widget = new TabWidget(this);
widget.setId(android.R.id.tabs);
FrameLayout content = new FrameLayout(this);
content.setId(android.R.id.tabcontent);
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(widget);
layout.addView(content);
tabHost.addView(layout);
setContentView(tabHost);
TabHost.TabSpec tab1 = tabHost.newTabSpec("tab1");
tab1.setIndicator("Tasks");
tab1.setContent(new Intent(this, TasksActivity.class));
try {
tabHost.addTab(tab1);
} catch (Exception e) {
e.toString();
}
TabHost.TabSpec tab2 = tabHost.newTabSpec("tab2");
tab2.setIndicator("Employee");
tab2.setContent(new Intent(this, EmployeeActivity.class));
tabHost.addTab(tab2);
tabHost.setCurrentTab(0);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question