3

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.

Community
  • 1
  • 1
Primal Pappachan
  • 25,857
  • 22
  • 67
  • 84
  • You need to post the stacktrace from LogCat if your application is crashing. – Mark B Apr 22 '10 at 15:33
  • I got the application to work. The problem was with pic I used as the drawable. I used a .jpg which was the root of trouble. Used a .png type and it worked with no troubles.. – Primal Pappachan Apr 23 '10 at 14:14
  • 4
    Interesting that png works but not jpg. btw: Put your resolution as answer and then close it. (I was just going to reply that another tab example with code is here: http://stackoverflow.com/questions/3103062/android-tabhost-activities-within-each-tab/3103156#3103156, but you already found an answer to your problem yourself :) – Mathias Conradt Jun 26 '10 at 08:01

2 Answers2

1

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.

Primal Pappachan
  • 25,857
  • 22
  • 67
  • 84
0

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.

Robert Massaioli
  • 13,379
  • 7
  • 57
  • 73