android-tabhost

How to avoid starting the activity at the first tab in a TabActivity?

二次信任 提交于 2020-01-05 19:59:31
问题 i want to avoid starting activity in the first tab .. tabHost.setCurrentTab(1). When the tab activity starts, I expect that only the activity in tab 2 gets started. But, currently, Android starts both activity in tab 1 and activity in tab 2, if I set tab 2 as default current tab import android.app.TabActivity; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.util.Log; import android.view.Window; import android.widget.TabHost; import

android Navigation Tabs in middle of screen

早过忘川 提交于 2020-01-04 03:38:06
问题 In my app i want to have tabs in the middle of the screen and a gMap at the top is there anyway to position the tabs in the middle of the screen? Here is a raw design (source: qnex.me) 回答1: You can use ViewPagerIndicator library (using TabPageIndicator control) with a ViewPager control, and these are completely separate from the ActionBar and can be positioned anywhere you like. Download the source and check out the sample app. The code is very straightforward. Here's an example straight from

Any Alternate method for Class Casting

本秂侑毒 提交于 2020-01-03 15:22:34
问题 Following statement is not executing on some devices. AddEvent act1 = (AddEvent) getLocalActivityManager().getCurrentActivity(); Is there any alternate method for above statement. On some devices it works fine but on other devices it gives exception. Edit: My application is developed in tab. OnActivity results is used for getting picture from camera activity. Dont know where the resides but when I puts the above statement in try catch then no force close occurs and exception is shown there.

Any Alternate method for Class Casting

非 Y 不嫁゛ 提交于 2020-01-03 15:21:26
问题 Following statement is not executing on some devices. AddEvent act1 = (AddEvent) getLocalActivityManager().getCurrentActivity(); Is there any alternate method for above statement. On some devices it works fine but on other devices it gives exception. Edit: My application is developed in tab. OnActivity results is used for getting picture from camera activity. Dont know where the resides but when I puts the above statement in try catch then no force close occurs and exception is shown there.

android, dynamically change a fragment inside a tab

好久不见. 提交于 2020-01-03 03:59:05
问题 I'm trying to change the content of a tab that was created using FragmentTabHost and getSupportFragmentManager() , but I'm not sure how to do it. Here is what I have: mTabHost = new FragmentTabHost(this); setContentView(mTabHost); mTabHost.setup(this, getSupportFragmentManager(),R.id.menu_settings); mTabHost.addTab(mTabHost.newTabSpec("A").setIndicator("A"), A.class, null); mTabHost.addTab(mTabHost.newTabSpec("B").setIndicator("B"), B.class, null); mTabHost.addTab(mTabHost.newTabSpec("C")

Android TabHost is there a way to get TabView by ID

主宰稳场 提交于 2020-01-02 10:35:33
问题 I'm making some an advanced TabActivity but I need to get every TabView thats in the TabHost . With tabHost.getCurrentTabView() I can get the current TabView but is there a way to get a TabView by its ID? I managed to make a workaround by doing a for loop in the onCreate() method where I go to every tab and put all the View objects in an Array. private View[] tabs; for(int i = 0; i < getTabWidget().getTabCount(); i++) { tabHost.setCurrentTab(i); tabs[i] = tabHost.getCurrentTabView(); } 回答1:

How to change the color of tab indicator

蓝咒 提交于 2020-01-02 10:28:35
问题 I am using tabHost in my application and the requirement is that when any tab is selected the color of tab indicator should change ,I referred this example How to set Tab View Indicator background color in Android but i didn't understood Here is my code: TabHost tabHost = getTabHost(); // The activity TabHost TabHost.TabSpec spec; // Reusable TabSpec for each tab Intent intent; // Reusable Intent for each tab // Create an Intent to launch an Activity for the tab (to be reused) intent = new

How can we specify width for each tab in tabhost?

放肆的年华 提交于 2020-01-02 05:51:01
问题 I am using tabhost in my application. Can we give separate width property for each tab? i.e, one with larger width and other with smaller? 回答1: We can mention the tab width in code like: tabHost.getTabWidget().getChildAt(0).getLayoutParams().width = 50; 回答2: I tried below code and it worked perfectly fine for me LayoutParams params = tabHost.getTabWidget().getChildAt(0).getLayoutParams(); params.width = 170; params.height = 120; tabHost.getTabWidget().getChildAt(0).setLayoutParams(params );

How to set Android toolbar height?

早过忘川 提交于 2020-01-02 01:36:32
问题 I want to achieve this: What I thought was to make a Custom Toolbar with a bigger height and work with the tabhost and tabpager normally. I have implemented it, but the toolbar is showing the normal height, so it doesn't show as I want, just the top part. Is this the right approach or is it possible to set a TabHost below a Linear/Relative Layout? Because I don't need to work with it as an action bar. Relevant Code toolbar.xml <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget

android tabHost brakes listviews onArticleSelected

折月煮酒 提交于 2020-01-01 07:04:34
问题 I have a Main Drawer activity which loads my fragments when a drawer item is selected. The fragment that is laoded contains a tabhost which hosts multiple fragments so you can switch to via tabs. Before Tabs I had a fragment with a bunch of butons that when clicked, replaced the current fragment with a new fragment. The fragments all have listviews in them, and when you click an item replaced the current listview fragment with another fragment. My problem is when I placed all my fragments