Search Results

Search found 105 results on 5 pages for 'tabhost'.

Page 2/5 | < Previous Page | 1 2 3 4 5  | Next Page >

  • Force Tab Activity creation?

    - by Daniel
    I have a TabHost and several tabs added to it. Problem: The activities on these tabs are not created until the tab is pressed. My tabhost is broadcasting intents but my broadcast receivers are not registered until onCreate in my tab activities is called. Is there any way to force activity creation? Maybe my tabhost can call setCurrentTab and switch back to main tab(0), but is that really the best option available?

    Read the article

  • OnClickListener on Tabs not working

    - by Aracos
    Greetings, I am trying to get the Click - event when clicking on the currently selected tab of my TabActivity. The onTabChangedHandler is only called whenever the tab is changed, not if the currently active Tab is clicked. The debugger tells me i have the onClickListener Registered for the TabWidget within my TabHost. Am i registering for the wrong View? Also, I am unable to create a Context Menu for the Tabs, only for its content, is this problem related? public class TestDroidViewTab extends TabActivity implements TabContentFactory , OnTabChangeListener, OnClickListener { private static final String LOG_KEY = "TEST"; ListView listView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final TabHost tabHost = getTabHost(); TabHost.TabSpec ts = tabHost.newTabSpec("ID_1"); ts.setIndicator("1"); ts.setContent(this); tabHost.addTab(ts); ts = tabHost.newTabSpec("ID_2"); ts.setIndicator("2"); ts.setContent(this); tabHost.addTab(ts); ts = tabHost.newTabSpec("ID_3"); ts.setIndicator("3"); ts.setContent(this); tabHost.addTab(ts); tabHost.setOnClickListener(this); tabHost.setOnTabChangedListener(this); } public void onClick(View v) { Log.d(LOG_KEY, "OnClick"); } public void onTabChanged(String tabId) { Log.d(LOG_KEY, "OnTabChanged"); }

    Read the article

  • Changing tabs in android

    - by Pavel
    Hi guys. Can someone please tell me how to change tab by clicking on element INSIDE the tab? I already tried it with global data. The code looks like this: public class Tabs extends TabActivity { int tabNumber = 0; private TabHost tabHost; int returnedTabNumber = 0; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Resources res = getResources(); // Resource object to get Drawables tabHost = getTabHost(); // The activity TabHost TabHost.TabSpec spec; // Resusable 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 Intent().setClass(this, Tribocracy.class); // Initialize a TabSpec for each tab and add it to the TabHost spec = tabHost.newTabSpec("map").setIndicator("Map", res.getDrawable(R.drawable.ic_tab_artists)) .setContent(intent); tabHost.addTab(spec); // Do the same for the other tabs intent = new Intent().setClass(this, Areas.class); spec = tabHost.newTabSpec("areas").setIndicator("Areas", res.getDrawable(R.drawable.ic_tab_albums)) .setContent(intent); tabHost.addTab(spec); // Do the same for the other tabs intent = new Intent().setClass(this, Settings.class); spec = tabHost.newTabSpec("settings").setIndicator("Settings", res.getDrawable(R.drawable.ic_tab_albums)) .setContent(intent); tabHost.addTab(spec); tabHost.setCurrentTab(tabNumber); } protected void onResume() { super.onResume(); GlobalData globalData = ((GlobalData)getApplicationContext()); returnedTabNumber = globalData.getTabNumber(); tabHost.setCurrentTab(returnedTabNumber); } } The global adapter looks like this: public class GlobalData extends Application { //---------------------------------------------------- private int Point1; //define the vars here private int Point2; //define the vars here private int Point3; //define the vars here private int Point4; //define the vars here private int Point5; //define the vars here private int Point6; //define the vars here private int tabNumber; public int getTabNumber() //getter of the value { return tabNumber; } public int setTabNumber(int number) //setter of the value { tabNumber = number; return tabNumber; } } Now when I'm trying to change tab in my ListActivity tab by clicking on one of the items it doesn't do anything and stays on the ListActivity tab. Perhaps I shouldn't use onResume() here. Basically I want to go to first tab when I click on one of the items in the list. Please help!

    Read the article

  • TabHost Problem in android

    - by sairam333
    Hi, I want Access a single Activity using 2 different tabs.For Ex I have a single Activity like People and two tabs those names are tab1 and tab2.when i click on tab1 I want to display the people page as my group and when i click on tab2 that same page displayed the show all title.That means I want to Access a single Intent for two tabs In the same way the Information in that Activity is displayed According to Tab.For this purpose what can i do?Give me some suggestions.Thanks in advance.

    Read the article

  • webview in tabhost

    - by user1905845
    I am new to android. I am using webview inside tabview. In my app in first activity facebook button available.when click facebook button connect to facebook in second activity inside tabs fine.In second activity i am using webview. this is the code. public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.facebook); wvFacebook=(WebView)findViewById(R.id.webview); btnBack=(Button)findViewById(R.id.back); txtBarname=(TextView)findViewById(R.id.barnameheader); if(check==1){ strFacebook=MyBarsActivity.strFacebook; Log.e("Facebook url",strFacebook); strBarName=MyBarsActivity.strBarName; } wvFacebook.setWebViewClient(new MyWebViewClient()); wvFacebook.loadUrl(strFacebook); } private class MyWebViewClient extends WebViewClient { public boolean shouldOverrideUrlLoading(WebView view, String url) { view.getSettings().setJavaScriptEnabled(true); view.loadUrl(url); return true; } @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); // progressDialog.show(getParent(), "In progress", "Loading, please wait..."); } public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); } But my problem is when i click connect button facebook page will be displayed well inside tabs.But when i click emial or username and password button it is not responding.Why it is not responding please help me regarding this.thanks in advance.

    Read the article

  • Android Title bar leaving space in when application is resumed

    - by user466607
    I am using a Tab Host in my Android App. I have the Titlebar hidden. When I leave the App and resume to it, I have some strange behaviour. If I resume to a tab using a list activity with listView.setAdapter, the title bar is hidden and the space it takes up is consumed by the App. However, if I resume to any tab without the listView.setAdapter, the Titlebar is hidden, but space which was used by it is left behind. This is pushes my tabs (which are positioned at the bottom of the screen) off the screen. The space is once again consumed by my app if I then change to any other tab. I have tried to invalidate most of the obvious Views in my App without and success. Below is my tab_activity xml. many thanks <?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 xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" /> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0" /> </LinearLayout> </TabHost> </LinearLayout> Here is the Manifest <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.tar.projectx" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.CALL_PHONE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_CONTACTS" /> <application android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> <activity android:name=".Splash" android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" android:label="@string/app_name" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="SearchActivity" android:label="SearchActivity" android:screenOrientation="portrait"></activity> <activity android:name="SearchListActivity" android:label="SearchListActivity" android:screenOrientation="portrait"></activity> <activity android:name="ContactActivity" android:label="ContactActivity" android:screenOrientation="portrait"></activity> </application> </manifest> Interestingly, if I use the code below in the onResume method of my mainActivity which holds the tabhost, once the toast disappears, the view is refreshed and the space at the top is taken up by my app again. Obviously, this isn't much of a fix, but may help someone understand what is happening. @Override protected void onResume() { super.onResume(); Toast.makeText(this, "Welcome Back", Toast.LENGTH_LONG).show(); }

    Read the article

  • Exception in Tab program

    - by Kooper
    Here is main code: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Resources res = getResources(); TabHost tabHost = getTabHost(); Intent intent= new Intent(); intent.setClass(this,EGCQuery.class); tabHost.addTab(tabHost.newTabSpe("egcquery").setIndicator ("EGCQuery", res.getDrawable(R.drawable.egcquery)) .setContent(intent)); tabHost.addTab(tabHost.newTabSpec("patientinfo").setIndicator("PatientInfo", res.getDrawable(R.drawable.patientinfo)) .setContent(R.layout.main2)); tabHost.addTab(tabHost.newTabSpec("compinterp").setIndicator("Comp_Interp", res.getDrawable(R.drawable.compinterp)) .setContent(R.layout.main3)); tabHost.setCurrentTab(0)

    Read the article

  • An Exception occur in Tablayout.

    - by Kooper
    I wanna add three layout in a TabActivity, but it was force closed when I ran it. Here is the code: import android.app.TabActivity; import android.content.res.Resources; import android.os.Bundle; import android.widget.TabHost; public class Test1 extends TabActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Resources res = getResources(); TabHost tabHost = getTabHost(); tabHost.addTab(tabHost.newTabSpec("egcquery").setIndicator("EGCQuery").setContent(R.layout.main1)); tabHost.addTab(tabHost.newTabSpec("PatientInfo").setIndicator("PatientInfo").setContent(R.layout.main2)); tabHost.addTab(tabHost.newTabSpec("Comp_Interp").setIndicator("Comp_Interp").setContent(R.layout.main3)); } }

    Read the article

  • Switch between views in Android

    - by ZelluX
    Hi, all I'm writing an Android application with multiple Tabs. The content of each tabs is determined by XMLs on the Internet, and it could be WebView for HTML rendering, GridView for photo displaying, etc. I'm going to delay downloading of those XML until the tab is clicked. Upon clicking the application will download corresponding XML from the Internet, and then choose suitable View for it. Currently I have written a MyViewDelegate and use TabSpec.setContent() to set the spec pointing to MyViewDelegate: spec = tabHost.newTabSpec(tabName[i]); intent = new Intent().setClass(this, HomeActivity.class); spec.setIndicator(title[i]); spec.setContent(new MyViewDelegate(this, tabName[i])); tabHost.addTab(spec); My problem is, after MyViewDelegate is required to draw, how can I switch to WebView/GridView and initialize it? Many thanks.

    Read the article

  • Android: Help with tabs view

    - by James
    So I'm trying to build a tabs view for an Android app, and for some reason I get a force close every time I try to run it on the emulator. When I run the examples, everything shows fine, so I went as far as to just about copy most of the layout from the examples(a mix of Tabs2.java and Tabs3.java), but for some reason it still wont run, any ideas? Here is my code(List1.class is a copy from the examples for testing purposes). It all compiles fine, just gets a force close the second it starts: package com.jvavrik.gcm; import android.app.TabActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.TabHost; import android.widget.TextView; public class GCM extends TabActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final TabHost tabHost = getTabHost(); tabHost.addTab(tabHost.newTabSpec("tab1") .setIndicator("g", getResources().getDrawable(R.drawable.star_big_on)) .setContent(new Intent(this, List1.class))); tabHost.addTab(tabHost.newTabSpec("tab2") .setIndicator("C") .setContent(new Intent(this, List1.class)) ); tabHost.addTab(tabHost.newTabSpec("tab3") .setIndicator("S") .setContent(new Intent(this, List1.class)) ); tabHost.addTab(tabHost.newTabSpec("tab4") .setIndicator("A") .setContent(new Intent(this, List1.class)) ); } }

    Read the article

  • Android: Replace a TabSpec Content

    - by Ally
    I have a TabHost with a bunch of tabs each with a TabSpec. I'd like to change the content of one of the TabSpecs but I don't seem to be able to. I've read a few places that it's not possible to change the content of a TabSpec. Does anyone know why I can add/remove tabs but not change the content of them? And can anyone suggest a workaround for this problem?

    Read the article

  • Automatically add "More..." Tab in Android

    - by ZelluX
    Hi, all I'm writing an application which contains many tabs, and sometimes the number of tabs may exceed five. So I want to make it behave like iPhone, which is, move additional tabs to a "More..." tab. I would like to know if this feature is supported by TabHost, or if there is any existing open source widget which can do the favor for me. Thanks.

    Read the article

  • ListView items not responding to tap

    - by Justin Williams
    I'm just getting my feet wet with Android and have built a UI that contains a TabHost with three tabs. Each tab is powered by its own Activity. The first Tab contains a listview with a prepopulated set of rows and is built from a custom ArrayAdapter. The problem I'm running into is that none of the ListView rows are tappable. In other words, when I tap on them there is no orange selection. If I use the scroll ball on my Nexus One it will select, but any touch gestures don't seem to be responding. All the UI is being handled using XML files with a main.xml housing the TabHost - LinearLayout - TabWidget/FrameLayout and a nearby_activity.xml file containing my ListView UI <?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"> <TextView android:id="@+id/android:empty" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="@string/nearby_no_events" /> <ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1.0" android:choiceMode="multipleChoice" android:divider="#d9d9d9" android:dividerHeight="1px" android:cacheColorHint="#eee" /> </LinearLayout> And the relevant code from my Activity that is set to show in the selected tab. public class NearbyActivity extends ListActivity { private ArrayList<Event> m_events = null; private EventAdapter m_adapter = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.nearby_activity); getEvents(); this.m_adapter = new EventAdapter(this, R.layout.eventrow, m_events); setListAdapter(this.m_adapter); } private void getEvents() { m_events = new ArrayList<Event>(); for (int i = 0; i < 100 ; i++) { Event e = new Event(); e.setEventName("Event " + i); e.setVenueName("Staples Center"); e.setStartDate(new Date()); m_events.add(e); } } private class EventAdapter extends ArrayAdapter<Event> { private ArrayList<Event> items; public EventAdapter(Context context, int textViewResourceId, ArrayList<Event> items) { super(context, textViewResourceId, items); this.items = items; } @Override public View getView (int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.eventrow, null); } Event e = items.get(position); if (e != null) { TextView nameText = (TextView)v.findViewById(R.id.eventName); TextView venueNameText = (TextView)v.findViewById(R.id.venueName); if (nameText != null) { nameText.setText(e.getEventName()); } if(venueNameText != null) { venueNameText.setText(e.getVenueName()); } } return v; } } } My listview row's are populated by an XML file as well. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:orientation="vertical" android:padding="4dip"> <TextView android:id="@+id/eventName" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:inputType="text" android:singleLine="true" android:ellipsize="marquee" android:textSize="18sp" android:textColor="#000" /> <TextView android:id="@+id/venueName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/eventName" android:layout_alignParentBottom="true" android:layout_marginRight="55dip" android:singleLine="true" android:ellipsize="end" android:scrollHorizontally="true" android:textSize="13sp" android:textColor="#313131" android:layout_alignWithParentIfMissing="true" android:gravity="center_vertical" /> </RelativeLayout> Thanks for any help you can offer.

    Read the article

  • A Tab Exception Message

    - by Kooper
    06-14 00:21:30.398: ERROR/AndroidRuntime(332): Caused by: java.lang.RuntimeException: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost' what it means? I've already given the id for tabhost.And I can see the id in R.java. Here is the .xml: TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent" LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp" TabWidget android:id="@+id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" FrameLayout android:id="@+id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp" LinearLayout TabHost

    Read the article

  • Customizing TabWidget in SDK 1.5, API 3

    - by Dylan McClung
    I'm aware that API 3 doesn't allow a view to be set for a tab, but I still need to modify the TextView displayed as the indicator. I'd also like to change the Drawable for the tab, but I don't see a way to do it without a custom tab view as allowed in 1.6, API 4. Working with this generic example below, is there way to retrieve the TextView and modify its properties or change the drawable? TabHost tabHost = getTabHost(); TabHost.TabSpec spec; spec = tabHost.newTabSpec("nearby") .setIndicator("Nearby Activity") .setContent(R.id.nearby_list); tabHost.addTab(spec); spec = tabHost.newTabSpec("friends") .setIndicator("Friends & Favorites") .setContent(R.id.friends_list); tabHost.addTab(spec); tabHost.setCurrentTabByTag("nearby"); Thanks for any help.

    Read the article

  • android : Dynamically changing the content of tab

    - by Jomia
    I want to change the content of a tab? when tha tab is created i set the content of the tab by setContent() method. But if I click again, I want to change the content that means change to another activity. I used setOnTabChangedListener() method, but I am not sure about how to set the content to another intent? Resources res = getResources(); TabHost tabHost=getTabHost(); tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("HOME").setContent(new Intent(getBaseContext(),homeGroup.class))); tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("ABOUT US").setContent(new Intent(getBaseContext(),aboutusGroup.class))); tabHost.setCurrentTab(0); tabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { //here i want to set the content of each tab to another intent // for 'tab1', change to home.class // for 'tab2', change to aboutus.class //how to set these? } }); Please help me.. Thank you..

    Read the article

  • Admob ads will not display when placed inside a tabview

    - by smith324
    I've been trying to get my ads to display in this type of layout. Tabs - LinearLayout - ListView - header. The header is set via addHeaderView and is displaying normally. If I were to move the ads anywhere else they display normally (so its not a setup issue). Using ads in the header of a listview works fine in my other projects. So this seems to be a very specific problem, the ads simply refuse to display when placed in the header of a listview inside a tabhost. My logs show no activity from admob at all. There is either a bug here or limitation of the sdk. Does anyone have any experience or insight into this issue? EDIT I found the solution. It actually had to do with padding that was in the root of my Tabview. For more checkout my answer here

    Read the article

  • Why is my onSharedPreferenceChangeListener being called multiple times when I change a pref.

    - by brockoli
    I've written an app with 3 tabs. Each tab has the same list view with different data sources. I have setup SharedPreferences in the tabhost activity, but I put my onSharedPreferenceChangeListener method in my listactivity. When I change a preference, my listener gets called and it updates my database. This is all working. However, if I change the data in tab 1, it calls my listener once. If I change the data for tab 2 it calls it twice and if I change the data in tab 3 it calls it three times. Any idea why it works this way? I guess I could setup my shared prefs in my listactivity and that might avoid the issue, but I'm curious why my listener is called multiple times if it's in a different tab. brockoli

    Read the article

  • Emulate back button in multi-view TabActivity

    - by ZelluX
    Hi, all I have a TabActivity with several tabs. Each tab corresponds to a specific view, and those views may further switch to other views. For example, one of my tabs displays RSS feed list, after user clicks one of the RSS feed, it will switch to a view displaying a list of articles, and after user clicks one of the titles, a full article view will be displayed. I'm going to add support for "back" button in my application. For instance, in a full article view, after user presses the "back" button, it should switch back to the article list view. And if user presses it the "back" button again, my application should switch back to the feed list view. My idea is to maintain a Stack<View> during navigation, and every time user presses the "back" button, the program will pop a View out of the stack, and set it as the current view. But I would like to know how to set current view in TabHost. Many thanks.

    Read the article

  • Making simple tabs in android

    - by user2910566
    I am new to Android. I am making a tab Activity that has 3 tabs in it. . I came across reading some interesting articles that tab can be made in three ways:: Regular TabHost Using simple Fragments Using Action Bar Sherlock I have a set of questions Which is a better choice & why ? Which gives more flexibility, efficiency & performance ? Which would be the preferd choice in case of requirement changes happen in future ? My research indicate :: ActionBarsherlock is better ! Is there something better than this ? If so what is it ?

    Read the article

  • Strange options menu behavior in Android TabActivity

    - by jboxer
    I have a TabActivity with four tabs (each is its own Activity). Each tab defines its own onCreateOptionsMenu (and in some cases, onPrepareOptionsMenu). When each tab is loaded, an AsyncTask is kicked off to retrieve the data needed to populate that tab's list. If I switch between tabs very quickly (while they're still loading) and then press the menu button (while the current tab's AsyncApiTask is still running), I'm able to get the wrong options menu to appear. For example, let's say FooActivity (tab 1) has an options menu with a "Refresh" item, and BarActivity (tab 2) has an options menu with a "View All" item. If I start the app (with tab 1 active), quickly switch to tab 2, and then hit menu, the "Refresh" item (rather than the expected "View All" item) will sometimes show. Furthermore, while this weird behavior sometimes occurs just on the first menu press (and later presses show the right items), sometimes it gets "stuck", and the wrong items show up on every press until I switch tabs. Any idea what could be going on? I haven't heard of this happening before, and haven't been able to find any good suggestions.

    Read the article

< Previous Page | 1 2 3 4 5  | Next Page >