android-tabhost

Modify tab indicator dynamically in Android

旧时模样 提交于 2020-01-01 04:18:05
问题 My application needs to update tab indicator dynamically, I'm trying to do this by invoke TabSpec.setIndicator(), but it doesn't work. Here is my code: In onCreate method of TabActivity: tabHost = getTabHost(); TabSpec tabSpec = tabHost.newTabSpec("abc"); tabSpec.setIndicator("helloabc"); tabSpec.setContent(new MyViewFactory()); tabHost.addTab(tabSpec); Now I need to change tab indicator to another string, for example, "xyz" TabSpec tabSpec = MyTabActivity.getTabSpec(); tabSpec.setIndicator(

Android - How to create tabs on demand using existing layout?

江枫思渺然 提交于 2019-12-31 05:42:11
问题 Compulsory background info: I'm building a tablet app for real estate agents to use when quoting homes and buildings. Since a home or an apartment can have any number of rooms, I thought it would be nice to build a tab-based solution that allowed for going room by room and creating one tab per room on demand. I've been through several tab tutorials but all solutions I've found deal with a predefined number of tabs, and use the deprecated TabHost. TabHost.TabSpec ourSpec = tabhost.newTabSpec(

How to create center raised tabbar?

狂风中的少年 提交于 2019-12-30 02:34:06
问题 I want to create the TabBar as like Below image: Here, all tab bar are normal. Just they are custom made. Now i want to create the Tab Bar as like above image. In which the center Tab is raised. So what should i have do to make it possible ? If is there any demo then it will be good. Please help me. 回答1: you can set the Background image in Tab widget as tabHost.getTabWidget().getChildAt(0).setBackgroundResource(R.drawable.home_h); tabHost.getTabWidget().getChildAt(1).setBackgroundResource(R

How to switch tabs programmatically in Android from fragment?

被刻印的时光 ゝ 提交于 2019-12-30 00:51:33
问题 I have implemented a TabActivity which extends FragmentActivity . It has 5 tabs each tab is a Fragment . What i am looking for is to switch between the tabs programmatically. For eg: if i am in tab4. On button click I want to move from tab4 to tab1 . Tried a lot but couldn't find the solution for this. Tried with the following but it doesn't help. From SecondTab public void switchTabInActivity(String value){ FirstTab parent; parent = (FirstTab) getActivity().getParent(); parent.switchTab

Setting selected TAB with a small triangle below it

浪子不回头ぞ 提交于 2019-12-28 13:56:13
问题 I want my tabs to show like in the image with small triangle below it.Is this possible ?If yes, then help me with some codes or documentation. 回答1: I think, the following approach is the simplest one. You just need to setup the following drawable (actually, it's Android's default drawable for tabs) as a background of the tabs: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Non focused states --> <item android:state_focused=

Issues with Android TabHost Example

喜欢而已 提交于 2019-12-28 02:05:01
问题 I have been attempting to implement the 'advanced' tabwidget example from google. But, when it tries to call tabHost.addTab(spec); I get a stack trace from the debugger. Sorry, I don't have the stack trace here, but I'm wondering if others have had this same issue (as this code had a number of typo's and missing information that stopped me from even compiling. Can anyone point me to a corrected/running version of this code? The updated information needed are: <activity android:name="

Issues with Android TabHost Example

喜欢而已 提交于 2019-12-28 02:04:32
问题 I have been attempting to implement the 'advanced' tabwidget example from google. But, when it tries to call tabHost.addTab(spec); I get a stack trace from the debugger. Sorry, I don't have the stack trace here, but I'm wondering if others have had this same issue (as this code had a number of typo's and missing information that stopped me from even compiling. Can anyone point me to a corrected/running version of this code? The updated information needed are: <activity android:name="

Android remove space between tabs in tabwidget

≡放荡痞女 提交于 2019-12-27 11:11:27
问题 I have made an application which has tabs like in HelloTabActivity, there is also space between these tabs, can anyone suggest how to remove this space and also there is a grey line beneath the tabs how can that be removed? main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TabHost android:id="@android:id/tabhost" android

TabHost: first loaded tab stays in background after switching tabs

纵饮孤独 提交于 2019-12-27 01:45:07
问题 EDIT: Same stuff happening when I used TabLayout+ViewPager. One of my Fragments has a TabHost with 4 tabs. The following only happens with dark theme active ( AppCompatDelegate.MODE_NIGHT_YES ). When the fragment is shown for the first time and I change the tab, a ghost effect happens and the first tab stays in the background: It does not matter which tab is default and which one is clicked after - any combination causes this: When I exit the fragment and come back, then it is fine. This is

Tab Application Crash during runtime

限于喜欢 提交于 2019-12-25 13:19:14
问题 I am new to android development and I've been creating an application containing two tabs . in one tab a Grid containing images will be displayed and on the other another page will be displayed . I've created 3 XML layout files and 3 java class files whose code is given below . (I'll be writing the code for pageActivity.java later on ) MainActivity.java public class MainActivity extends TabActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState