android-tabhost

How to programmatically switch tabs using buttonclick in Android

久未见 提交于 2019-11-27 03:53:44
问题 I have been struggling with this for a few days now. I'm trying to switch tabs programmatically upon a button click. My program works flawlessly if I just use the tabs to change activities, but wiring an onClick method with setCurrentTab results in an error. This is the method that will not work. It's a pretty basic and straightforward function but I haven't seen much documentation or examples of people attempting to wire a buttonclick with switching tabs. Thanks. ImageButton next =

java.lang.IllegalStateException: No activity

心不动则不痛 提交于 2019-11-27 02:49:14
问题 I'm building an Android app for which I'd like my first activity to be composed of 2 tabs, one for the user's profile, and one for the friends' activity. For these tabs, I opted for a TabHost since my Sherlock Action Bar is already using list navigation to move to other activities so I can't use tab navigation from the action bar. The app worked for a while, but now only one of my tabs works, as soon as I try to move to the second tab, I'm getting a java.lang.IllegalStateException: No

Android - Tabhost working in Activity class

耗尽温柔 提交于 2019-11-27 02:17:49
问题 OK, I must be overlooking something silly because I am unable to get my tabhost to display in my Activity class. I am getting the dreaded force close when I try to run the app. It will work if i extend TabActivity, but I can't do that [see edit below] because once I move the code from my prototype project its going to be in a custom class that inherits from Activity. Here is the XML layout: <?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res

Android TabHost - Activities within each tab

六月ゝ 毕业季﹏ 提交于 2019-11-27 01:42:53
问题 I'm trying to create multiple Tabs, each with a different Activity. The only downside is i'm using a custom layout file thus my class extends an Activity rather than a TabActivity . While trying to run, it fails and suggests calling TabHost.Setup(ActivityGroupManager agm) Anyone have an idea/practical example of how this can be achieved? Thanks in advance 回答1: This is a sample of my activity that also doesn't extend from TabActivity: protected TabHost tabs; // ... /** * Init tabs. */ private

android: using ActivityGroup to embed activities

折月煮酒 提交于 2019-11-27 01:09:27
Im in the conceptualizing/design phase of building an app and i've hit a bit of a snag. Essentially i was looking for a way to embed one activity into the UI of another similar to how a TabHost/TabActivity. There would be a window at the top of the screen which would contain the other activity, and below that would be buttons and controls that are independent of the above activity and should always be visible. The user would be able to navigate from one activity to another in the window without causing any change to the below controls. While looking into the issue i ran across ActivityGroup,

Updating Android Tab Icons

这一生的挚爱 提交于 2019-11-27 00:34:49
问题 I have an activity which has a TabHost containing a set of TabSpecs each with a listview containing the items to be displayed by the tab. When each TabSpec is created, I set an icon to be displayed in the tab header. The TabSpecs are created in this way within a setupTabs() method which loops to create the appropriate number of tabs: TabSpec ts = mTabs.newTabSpec("tab"); ts.setIndicator("TabTitle", iconResource); ts.setContent(new TabHost.TabContentFactory( { public View createTabContent

Android - TabActivity with Transition animation

拜拜、爱过 提交于 2019-11-26 22:59:50
问题 I'm trying to add an animation to my TabActivty. For example, when the user select the 2nd tab, I want the new activity comes from the right. When the user select the first tab, I want the activity comes from the left. I've found how to add one animation, but I want to add one again. Here is the code I'm using: public Animation inFromRightAnimation() { Animation inFromRight = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO

Android TabWidget detect click on current tab

廉价感情. 提交于 2019-11-26 21:56:34
I am trying to find way to be able to fire an onclick event on a tab when this tab is the current tab. I did try this way (among several other) with no success thou. public void onTabChanged(String tabId) { Log.d(this.getClass().getName(), ">>>>>>>>>>>>>>>>>>>>>>>> tabId: " + tabId); int tabs = getTabWidget().getChildCount(); Log.d(this.getClass().getName(), "tabs: " + tabs); for(int i=0; i<tabs; i++){ View tab = getTabWidget().getChildAt(i); if(i==tabHost.getCurrentTab()){ Log.d(this.getClass().getName(), "tab: " + i); tab.setOnClickListener(this); }else{ tab.setOnClickListener(null); tab

How to change the Tabs Images in the TabHost

不羁岁月 提交于 2019-11-26 21:51:39
I am using the TabHost in my application, I am using four Tabs in my application and I want to use the different Images in the TabHost when the Particular Tab is been Selected and not selected. I need to use to different Images for a particular tab each. When I Select any Tab the Image is little bright and when I switch to another Tab that bright Image becomes grey shaded. I have implemented the TabHost but I don know how to change the Images in the TabHost. Can anybody help me in this. Thanks, david If you wish to use different images for the selected and unselected states, then create

Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'

点点圈 提交于 2019-11-26 20:59:59
问题 I have a problem: Java Code public class VisualizzaListaActivity extends TabActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); 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