android-tabhost

How do I change the color used to indicate a tab has been selected on a TabHost?

前提是你 提交于 2019-12-06 10:22:56
问题 On the android TabHost layout , when the user selects a tab the color of the tab changes temporarily. How do I either disable this color change, or specify the color that the tab changes to? 回答1: UPDATED Instead of making an own example and taking credit for it, I found my old bookmarked tutorial. How to change background on Android Tabs 回答2: I'll suggest you to implement your own tab_indicator_selector.xml. Example: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http:/

Android Tabhost Problem - .setIndicator

十年热恋 提交于 2019-12-06 05:56:01
问题 First let me clarify that i have already referred the SO question related to "Android - TAbhost". I have done googling about "Android Tabhost" but failed to find the solution. My problem is: If are having <3 tabs then it is fine. but Supporse if we are having 4 tabs with indicator title as TabHost1, TabHost2, TabHost3, TabHost4). But this title in Tab does not get fitted with tab. so is there any way to fit the Title Text (i.e. indicator) inside the tab ?? 回答1: I thought the source of our

Android FragmentTabHost

倾然丶 夕夏残阳落幕 提交于 2019-12-06 05:10:49
问题 I've already implemented FragmentTabHost, but my Fragments are going outside the tabhost. Here is my Activity: public class MainActivity extends ActionBarActivity { private FragmentTabHost mTabHost; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(),android.R.id.tabhost); mTabHost.addTab

Start Android App in a specific tab

故事扮演 提交于 2019-12-06 04:32:39
The question is: I have a TabHost with 4 tabs (see code below) and I got a Button in MainMenuActivity class. The Button is set up with a OnClickListener and if it is clicked I want it to go to the second tab. I have tried with setCurrentTab(1) but that just messed the project up. What can I do? public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); setTabs() ; } private void setTabs() { addTab("Home", R.drawable.tab_home, MainMenuActivity.class); addTab("Calculate", R.drawable.tab_search, SpinnerClass.class); addTab("Search", R

Create Smaller Tabs in Android

你说的曾经没有我的故事 提交于 2019-12-06 00:58:55
问题 I am trying to create smaller tabs in android -- but I can't seem to get it to work because all that happens when I create a smaller tab is that it shows the bigger tab -- but without a drawable. This is my layout code for tabs now -- but the height isn't wrapping for some reason -- it just goes to Android's usual layout height. <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill

android custom font for tabs

半城伤御伤魂 提交于 2019-12-06 00:10:01
I would like to have a custom font for my tabs. Here's what I have tried: <style name="CustomTabWidgetText" parent="@android:style/TextAppearance.Widget.TabWidget"> <item name="android:textSize">14sp</item> <item name="android:typeface">@assets/fonts/heartbre</item> <item name="android:textStyle">bold</item> </style> But I got an error in <item name="android:typeface">@assets/fonts/heartbre</item> . Has anybody here tried customizing the font of tabs? The only (currently) available way to set Fonts is to do it programatically : TextView tv= (TextView)findViewById(R.id.custom); Typeface face

Why does the first tab activity in Android live forever?

僤鯓⒐⒋嵵緔 提交于 2019-12-05 23:04:49
I've created a simple TabActivity which builds tabs at runtime reading some JSON data. At the moment I'm initializing an empty ListActivity with dummy random items for each tab just to see that changing from tab to tab works and the content doesn't disappear. The actual content for the tabs is stored in a singleton class, so when the tab activities get re-created due to a screen orientation change, they just pull the correct dummy items from the respective list according to an identifier contained in the intent's extras bundle. Everything works fine. I've put a log on the list activity

Android: TabActivity deprecated, use Fragments?

元气小坏坏 提交于 2019-12-05 18:51:28
问题 It appears that TabActivity is now deprecated, we need to use Fragments. I tried using a standard Activity but couldn't call getTabHost. So it appears i have to use Fragments. But i am a little confused how this would work. I understand that fragments are not activities so they are not in the manifest file? SO i presume i can't do startActivity on a fragment? Does anyone know of a good example explaining the tabHost and Fragments, all the examples and tutorials i have found are only using the

Tabhost tutorial broken? [duplicate]

≡放荡痞女 提交于 2019-12-05 16:18:05
Possible Duplicate: Anyone know what this error mean for android tabs? I have been trying to do the TabHost tutorial in the SDK but for some reason, is appears to break. On Step 4 I copy and paste the xml code, I get an error that prevents it from inflating properly. the error is: Error in an XML file: aborting build. This is in the graphical layout of the xml file. Error during post inflation process: TabHost requires a TabWidget with id "android:id/tabs", View found with id "tabs" is 'com.android.layoutlib.bridge.MockView' The xml file Itself has this in it. <?xml version="1.0" encoding="utf

Android OnResume not called when using TabHost and LocalActivityManager

一个人想着一个人 提交于 2019-12-05 15:36:33
I set up a tabhost with two activities and since I could not use TabActivity I used LocalActivityManager, but when I switch tabs onResume is not called for the Activities within the tabs. Here is my set up: mlam = new LocalActivityManager(this, false); mlam.dispatchCreate(savedInstanceState); tabHost = (TabHost) findViewById(android.R.id.tabhost); tabHost.setup(mlam); I have the dispatchResume and dispatchPause placed in the proper places, but they only fire when the main tab activity gets an onResume or onPause. I tried to solve my issue by firing the dispatchResume on bab change but that