Android tabhost change text color style

You may change color of Tabhost text as follow. tabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) { tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor(“#FF0000”)); // unselected TextView tv = (TextView) tabhost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); //Unselected Tabs tv.setTextColor(Color.parseColor(“#ffffff”)); } tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.parseColor(“#0000FF”)); // selected TextView tv = (TextView) tabhost.getCurrentTabView().findViewById(android.R.id.title); //for Selected Tab tv.setTextColor(Color.parseColor(“#000000”)) } }); EDIT: … Read more

onActivityResult not call in the Fragment

The reason why this doesn’t work is because you are calling startActivityForResult() from within a nested fragment. Android is smart enough to route the result back to an Activity and even a Fragment, but not to a nested Fragment hence why you don’t get the callback. (more information to why that doesn’t work here or … Read more

How to change the font size of tabhost in android

You can define themes, use styles to achieve this: First you create the theme (name:CustomTheme) for your Activity in your res/values/styles.xml: <style name=”CustomTheme” parent=”@android:style/Theme”> <item name=”android:tabWidgetStyle”>@style/CustomTabWidget</item> </style> <style name=”CustomTabWidget” parent=”@android:style/Widget.TabWidget”> <item name=”android:textAppearance”>@style/CustomTabWidgetText</item> </style> <style name=”CustomTabWidgetText” parent=”@android:style/TextAppearance.Widget.TabWidget”> <item name=”android:textSize”>20sp</item> <item name=”android:textStyle”>bold</item> </style> Then in your androidManifest.xml you specify the theme above for your TabActivity or Activity … Read more

Issues with Android TabHost Example

I spent the last hour or so going through that tutorial. Here’s the problems and fixes for it that I dealt with: Step 2: When creating your activities, if you do not create them through the manifest then you’ll need to add them to the manifest manually. Add these lines to AndroidManifest.xml: <activity android:name=”.AlbumsActivity” android:label=”@string/app_name” … Read more

android: using ActivityGroup to embed activities

Yes, you’d implement an ActivityGroup, which will be the container of your other Activities. When the user clicks one of the buttons, you’d get a reference to the LocalActivityManager, and use it to start, and embed the inner activity. Something like this: LocalActivityManager mgr = getLocalActivityManager(); Intent i = new Intent(this, SomeActivity.class); Window w = … Read more

Android TabWidget detect click on current tab

After gothrough many solutions for tab listener, I have found very simple solution… getTabHost().setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { int i = getTabHost().getCurrentTab(); Log.i(“@@@@@@@@ ANN CLICK TAB NUMBER”, “——” + i); if (i == 0) { Log.i(“@@@@@@@@@@ Inside onClick tab 0”, “onClick tab”); } else if (i ==1) { Log.i(“@@@@@@@@@@ Inside onClick … Read more

How to change the Tabs Images in the TabHost

If you wish to use different images for the selected and unselected states, then create ‘selector’ XML files in your drawables folder for each tab, e.g. tab1_selector.xml, tab2_selector.xml which should contain the following, replacing the drawable references to your images for selected and unselected states. i.e. <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:state_selected=”true” android:drawable=”@drawable/tab1_selected_image” /> … Read more

Android how can i replace the deprecated tabhost?

“Deprecated” in Android means “we think there is a better solution that you should investigate”. Rarely does “deprecated” mean “it is unusable”. TabHost, AFAIK, works fine on Android 4.0. That being said, I would recommend considering switching to tabs in the action bar, using ActionBarSherlock to give you backwards compatibility to Android 2.1. UPDATE Besides, … Read more