android-tabhost

How to switch between tabs in Android?

╄→尐↘猪︶ㄣ 提交于 2019-12-11 04:15:04
问题 How do I switch between tabs from within one of the activities that is located inside the tab host? I need to complete the project by tomorrow. My project involves showing 3 tabs with varying content. So please help anyone. 回答1: If you added the tabs as activities you can use this code inside a tab child activity TabActivity main = (TabActivity) getParent(); // get the main 'TabActivity' from a Child (tab) TabHost tabHost = main.getTabHost(); // get a handle to the TabHost tabHost

Trying to change tab indicator color

扶醉桌前 提交于 2019-12-11 04:10:15
问题 I've generated a custom action bar here and everything works except for tabs. Tab indicator and tab background color stays the same no matter what. tab_indicator_ab_recorder.xml file: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Non focused states --> <item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_recorder" /> <item android:state_focused="false" android:state_selected=

TabHost inside of a Scrollview: always scrolls down when a Tab is clicked

允我心安 提交于 2019-12-11 03:19:13
问题 I have an Activity which has a Scrollview as the top level element. Inside there are some other Views and at some point there is a TabHost. You might get a better impression by looking at the screenshot. The TabHost has three tabs, each with another Activity that are launched by an Intent. Everything is working fine except one thing. Whenever I click on a Tab, the Scrollview automatically scrolls down as you can see over here. The TabHost is out of the screen afterwards. I simply don't want

How to use intent between tabs in java/Android?

百般思念 提交于 2019-12-11 01:30:49
问题 I would need to know how to handle the intent between tabs. For example, I have a tab activity with two tabs. First on content is a text view. another one is a map view. When i click that text view it redirects to the tab2. it can be easily achieved by setCurrentTab(1) or setCurrentTabByTag("tab2") methods. But i want to pass lat and long values to that Map Activity to drop pin. What is the better way to use intents or getter/setter in java? What do you prefer? if your answer is "Intents".

Android Activity.onWindowFocusChanged doesn't get called from within TabHost

ε祈祈猫儿з 提交于 2019-12-10 22:57:04
问题 I'm struggling with the problem that the .onWindowFocusChanged() doesn't get called in my custom Activity class. My setup: Two tabs (containing Activity_1 and Activity_2) in a TabHost, where the 2nd tab is selected by default: tabHost.setCurrentTab(currentTabIndex); In both Activities, I added the onWindowFocusChanged() override (because I need to preform calculations after the layout is done drawing): @Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged

LongClick in tabs

冷暖自知 提交于 2019-12-10 22:34:23
问题 Is there a way we can add setOnLongClickListener in Tabs?? Or is there any other way where i can call one activity when clicked on a tab and a different activity when long clicked on the same tab?? public class HelloTabWidget extends TabActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Resources res = getResources(); TabHost tabHost = getTabHost(); TabHost

Realizing a tab navigation inside an ActionBar navigation.

旧城冷巷雨未停 提交于 2019-12-10 19:29:36
问题 Heyho. I'm trying to realize a tab navigation inside an ActionBar navigation (with fragments), but i can't get it work! Is this possible? It would be curious if not... . This is what i already got: MainActivity.java ... import android.app.Fragment; import android.app.FragmentTransaction; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ActionBar bar =

Activity in TabHost

烈酒焚心 提交于 2019-12-10 16:47:38
问题 I use a TabHost. The below code to call AActivity. intent = new Intent().setClass(this, AActivity.class); spec = tabHost.newTabSpec("A").setIndicator("A", res.getDrawable(R.drawable.icon)).setContent(intent); tabHost.addTab(spec); And it is in the tab. But in AActivity I call BActivity. The BActivity will open new page, but not in the tab. How to let it on the tab frame? AActivity use below code to call BActivity: it = new Intent(this, BActivity.class); startActivity(it); 回答1: If you want to

how to design tab which onselect comes in center of a tabhost

二次信任 提交于 2019-12-10 12:11:39
问题 I just encountered a problem in layout design with tabhost . i need exactly the same design so that on selecting a tab it will come in cented of the screen. with design like in these pictures. 回答1: Currently ViewPagerIndicator is the best resource for getting this done without too much code. As for the same design you're going to have to do a little work yourself to get that done. If you look through the samples on the projects github you'll see some examples of how the ViewPagerIndicator can

Fragment dont show content of TabHost in second time

混江龙づ霸主 提交于 2019-12-10 11:08:15
问题 Well... I'm working with fragments, android.support.v4.widget.DrawerLayout, TabHost and ViewPager ... I have the following code: main_base.xml <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height="match_parent" /> <ListView android:id="@+id