android-tabhost

Custom Back Stack for each Fragment in TabHost in Android

你离开我真会死。 提交于 2019-11-26 20:46:09
问题 Since the TabActivity is deprecated I tried to replace it with Fragments which has been already mentioned in developer android website. But as you guys already know there was an issue about replacing tabs with fragments, since there will be only one activity ,which is Fragment Activity, there is no back stack for each of the fragments and as you can see in the other SO questions most of the developers were saying that you need to manage your own custom back stack as a solution. I have created

Remove old Fragment from fragment manager

萝らか妹 提交于 2019-11-26 20:13:30
I'm trying to learn how to use Fragment s in android. I'm trying to remove old fragment when new fragment is calling in android. You need to find reference of existing Fragment and remove that fragment using below code. You need add/commit fragment using one tag ex. "TAG_FRAGMENT". Fragment fragment = getSupportFragmentManager().findFragmentByTag(TAG_FRAGMENT); if(fragment != null) getSupportFragmentManager().beginTransaction().remove(fragment).commit(); That is it. Lokesh If you want to replace a fragment with another, you should have added them dynamically, first of all. Fragments that are

Custom tabs in android [closed]

烂漫一生 提交于 2019-11-26 20:06:49
问题 I'm having a really hard time understanding how to use custom tabs in android. I don't want to just be able to set the text and stuff. How can I change the size, and the image, and all that. I've googled and I can't find anything that makes sense 回答1: You can create XML layout file in /res/layout. Then you need inflate layout in View and set indicator. I use this code in my projects: private static View prepareTabView(Context context, int textId, int drawable) { View view = LayoutInflater

How to change the font size of tabhost in android

我只是一个虾纸丫 提交于 2019-11-26 20:04:08
How can the font size of the tabs be changed? I extend TabActivity for the tabs. 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

Android Exception: Did you forget to call 'public void setup (LocalActivityManager activityGroup)'

雨燕双飞 提交于 2019-11-26 18:50:59
MyCode: public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final TabHost tabHost = (TabHost) findViewById(R.id.tabhost); // LocalActivityManager mLocalActivityManager = new LocalActivityManager(this, false); tabHost.setup(); TabSpec tabSpecCheckIn = tabHost.newTabSpec(getResources().getText(R.string.button_check_in).toString()); tabSpecCheckIn.setIndicator(getResources().getText(R.string.button_check_in).toString(), getResources().getDrawable(android.R.drawable.star_off))

Android: TabHost without TabActivity

女生的网名这么多〃 提交于 2019-11-26 18:39:11
I want to create tabs without extending TabActivity. (The reason is that TabActivity cannot handle a custom titlebar as it seems). I have public class startTab extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mylayout); Resources res = getResources(); LocalActivityManager mlam = new LocalActivityManager(this, false); TabHost tabHost = (TabHost) findViewById(R.id.tabhost); tabHost.setup(mlam); TabHost.TabSpec spec; Intent intent; intent = new Intent().setClass(this, Show1.class); spec = tabHost.newTabSpec(

Best way to implement tabs in android?

与世无争的帅哥 提交于 2019-11-26 18:33:39
问题 I have read looked through some code that implements tabs on the bottom of the app's page. And there is no deprecated method/class inside the code, and to me it is a very easy and clean way to implements tabs. But I heard the new way of implementing tabs is to use fragments. So, which one is better? And why? XML: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"

TabHost with Fragments and FragmentActivity

泪湿孤枕 提交于 2019-11-26 17:20:06
I'm working on an Android App and I want to use 3 tabs for navigation using Fragments for each tab, but I don't know how to create the structure for doing it. I want to add each fragment separately because each one is different, but I don't know where to add them in FragmentActivity. I have these files. tabs_layout.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_height="match_parent" android:layout_width="match_parent"> <TabHost android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height=

Update tabs from a tab's activity in a Android TabHost

一个人想着一个人 提交于 2019-11-26 17:17:07
问题 I have a TabActivity and am going to have 3 or 4 tabs. In TabA, I would like to have an ExpandableListView, which will list products. I would like TabC to act as a sort of "shopping cart", probably with a ListView of itself. Is there a way to interact with the TabHost from the Activity? I would like to be able to click a button inside of TabA and have it update and switch to TabC. Is this possible? Can I get the Tab's activities call its parents methods? 回答1: If you implement your tabs as

onActivityResult not call in the Fragment

放肆的年华 提交于 2019-11-26 17:01:44
问题 The structure of the app is like this: tabHost (in Activity) -> contains -> TabFragment(extend base container fragment) 1. The code in Activity : tabHost.addTab( tabHost.newTabSpec("home").setIndicator("", getResources().getDrawable(R.drawable.btn_home)), HomeFragment.class, null); 2. The code in HomeFragment (Notice that HomeFragment is not the actual function but a container like this, and it extend BaseContainerFragment): public class HomeFragment extends BaseContainerFragment { public