Android: TabLayout not working

I tried the TabLayout tutorial from the official developers site. I did not copy it as such and some minor changes and corrections for typos in tut.

package com.org.example;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;

public class HalloTabLayout extends TabActivity {



    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Intent intent;
     TabHost tabhost = getTabHost();
     TabHost.TabSpec tabspec;
     Resources res = getResources();

        //For the Family Tab

        //Intent

        intent = new Intent().setClass(this, FamilyLayout.class);

        //Setting the tab

        tabspec = tabhost.newTabSpec("family").setIndicator("Family", res.getDrawable(R.drawable.tab_spec)).setContent(intent);

        tabhost.addTab(tabspec); 

      //Default tab to display

        tabhost.setCurrentTabByTag("family");
    }

}

As a first step and make sure the code is right, I wanted one tab to be displayed.

I added FamilyLayout activity to the AndroidManifest.xml file, as well as the changes made here. Problems with Android TabHost Example

But the application continues to crash at runtime in the emulator. Any help is appreciated.

[:] .jpeg (3,5 ), . , pic . , 1600 * 900 . , .

+3
2

.jpeg (3.5 ), . , pic . , 1600 * 900 . , .

+1

OP :

.jpeg (3.5 ), . , pic . , 1600 * 900 . , .

, . , .

0

Source: https://habr.com/ru/post/1742301/


All Articles