Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8352381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:56:51+00:00 2026-06-09T08:56:51+00:00

I got some sample code for TabLayout for Android and I modified it to

  • 0

I got some sample code for TabLayout for Android and I modified it to suit my needs.

The thing is that when I tried to re-write it I got some deprecation errors and when i opened the sample no errors appeared.

At first I thought it was the minSdkversion so i changed it in the sample but still nothing happened.

I can’t get the icons appear correctly in the tab so it might have something to do with this deprecation.

Can anyone enlight me? Here is my code:

package com.example.myapp;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost.TabSpec;
//notice that here eclipse won't let me import android.widget.TabHost
//but i use it when i create the tabhost variable

public class TabHost extends TabActivity {
    //the 'TabActivity' part above gets crossed-over although that doesn't happen
    //in the sample
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tab_host);

        android.widget.TabHost tabHost = getTabHost();
        TabSpec absSpec = tabHost.newTabSpec("Absences");
        absSpec.setIndicator("Absences", getResources().getDrawable(R.drawable.abs));
        Intent int1 = new Intent(this, Absences.class);
        absSpec.setContent(int1);
        tabHost.addTab(absSpec);
    }
}

and this is the sample :

package com.example.androidtablayout;

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

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

       TabHost tabHost = getTabHost();
        TabSpec photospec = tabHost.newTabSpec("Photos");
        photospec.setIndicator("Photos", getResources().getDrawable(R.drawable.icon_photos_tab));
        Intent photosIntent = new Intent(this, PhotosActivity.class);
        photospec.setContent(photosIntent);
        tabHost.addTab(photospec); 
    }
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:56:52+00:00Added an answer on June 9, 2026 at 8:56 am

    TabActivity is deprecated, you should use fragments and the compatibly library to implement tabs now. Google seems to be pushing this deprecation quite forcefully, and they have even replaced the documentation page with a “how to migrate” type page.So http://developer.android.com/reference/android/app/TabActivity.html now explains what needs to be done to port your code 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a source code file that started as a copy of some sample
I got some sample code for android.nfc.NfcSecureElement but it throws some error. The import
I've got some sample code that I'd like to refactor as I need it
I got some sample code from the net here: http://www.javadb.com/sending-a-post-request-with-parameters-from-a-java-class That works fine. It
I try to run sample code but got some error: The import javax.microedition.contactless cannot
I've got some R code that looks basically like this: compute.quantiles <- function(mu, type)
I'm looking at writing some code that performs shadow mapping, in DX9. The sample
Am working with web service. Got some sample code from internet. Got some error
I'm having problems with some sample code I got from Boulanger and Lazzarini's 'The
I've got a quite strange problem here. I'm calling some simple code via Ajax.Updater:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.