Question

I have created a tabbedActivity for an android app and when I remove one of the tabs and re add it I get the following error

06-28 17:14:22.803: E/AndroidRuntime(18564): FATAL EXCEPTION: main
06-28 17:14:22.803: E/AndroidRuntime(18564): java.lang.IllegalArgumentException: you must specify a way to create the tab indicator.
06-28 17:14:22.803: E/AndroidRuntime(18564):    at android.widget.TabHost.addTab(TabHost.java:221)
06-28 17:14:22.803: E/AndroidRuntime(18564):    at com.eema.EvacRouteTableActivity$AsyncMap.onPostExecute(EvacRouteTableActivity.java:248)
06-28 17:14:22.803: E/AndroidRuntime(18564):    at com.eema.EvacRouteTableActivity$AsyncMap.onPostExecute(EvacRouteTableActivity.java:1)
06-28 17:14:22.803: E/AndroidRuntime(18564):    at android.os.AsyncTask.finish(AsyncTask.java:631)
06-28 17:14:22.803: E/AndroidRuntime(18564):    at android.os.AsyncTask.access$600(AsyncTask.java:177)
06-28 17:14:22.803: E/AndroidRuntime(18564):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
06-28 17:14:22.803: E/AndroidRuntime(18564):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-28 17:14:22.803: E/AndroidRuntime(18564):    at android.os.Looper.loop(Looper.java:137)
06-28 17:14:22.803: E/AndroidRuntime(18564):    at android.app.ActivityThread.main(ActivityThread.java:5041)
06-28 17:14:22.803: E/AndroidRuntime(18564):    at java.lang.reflect.Method.invokeNative(Native Method)
06-28 17:14:22.803: E/AndroidRuntime(18564):    at java.lang.reflect.Method.invoke(Method.java:511)
06-28 17:14:22.803: E/AndroidRuntime(18564):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-28 17:14:22.803: E/AndroidRuntime(18564):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-28 17:14:22.803: E/AndroidRuntime(18564):    at dalvik.system.NativeStart.main(Native Method)

And here is my code:

        @Override
        protected void onPostExecute(Void unused) {

            dialog.dismiss();
            @SuppressWarnings("deprecation")
            TabActivity ta = (TabActivity) EvacRouteTableActivity.this.getParent();
            TabHost tabHost = ta.getTabHost();
            if (MapViewActivity.onCreateCalled >= 2){
                tabHost.getTabWidget().removeView(tabHost.getTabWidget().getChildTabViewAt(4));

                //Tab for the Map
                TabSpec mapSpec = tabHost.newTabSpec("Map");
                Intent mapIntent = new Intent(getBaseContext(), MapViewActivity.class);
                mapSpec.setContent(mapIntent); 
                tabHost.addTab(mapSpec);
                SystemClock.sleep(5000);
            }
            tabHost.setCurrentTab(4);
        }
    }
Was it helpful?

Solution

You should set a tab indicator

mapSpec.setIndicator("tab", res.getDrawable(R.drawable.icon));

or

mapSpec.setIndicator("tab");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top