K
K
Kamikaze10242015-04-03 14:04:06
Android
Kamikaze1024, 2015-04-03 14:04:06

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);
    }

How to defeat her?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kamikadze1024, 2015-04-03
@Kamikaze1024

70791d55bfea42c48f98c541637dad10.png

I
IceJOKER, 2015-04-03
@IceJOKER

Some resource R.* was not found, without the full text of the error you can’t tell which one

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question