Primal Pappachan
Primal Pappachan

Reputation: 26525

Android: TabLayout not working

I was trying the TabLayout Tutorial from official developers site. I didnt copy paste it as such and some minor changes and corrections to typos in the 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 to have a Single tab displayed.

I added the FamilyLayout activity to AndroidManifest.xml file and also made changes suggested in here. Issues with Android TabHost Example

But the application keeps crashing on run time in the emulator. Any help would be much appreciated.

[Solution:] I used a .jpeg of high resolution and size(3.5mb) which was cause of trouble. I changed it into a lower resolution, size pic and it worked without troubles. I found out via trial and error that images beyond 1600*900 will make apps crash. Not an exact statistic, but it may help.

Upvotes: 3

Views: 1390

Answers (2)

Primal Pappachan
Primal Pappachan

Reputation: 26525

I used a .jpeg of high resolution and size(3.5mb) which was cause of trouble. I changed it into a lower resolution, size pic and it worked without troubles. I found out via trial and error that images beyond 1600*900 will make apps crash. Not an exact statistic, but it may help.

Upvotes: 1

Robert Massaioli
Robert Massaioli

Reputation: 13477

OP Solved his own problem:

I used a .jpeg of high resolution and size(3.5mb) which was cause of trouble. I changed it into a lower resolution, size pic and it worked without troubles. I found out via trial and error that images beyond 1600*900 will make apps crash. Not an exact statistic, but it may help.

Doing this to get more questions answered. The OP can feel free to answer this himself and then mark that as answered.

Upvotes: 0

Related Questions