Skip to main content

Posts

Showing posts with the label tabbar

How to align your TabHost at the bottom of the screen

There is a simplest way to align Tabbar at the bottom of the page. The code is given below copy and download the code and try it... In the previous example we learned a simple example to add Tabs to our application.Only a small change can give you tabs at the bottom of the page. In the previous example the xml was like this... <TabHost xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent" tools:context=".MainActivity" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" ...

Change Tabbar Text (title) dynamically in Android - a simple example

Changing title of tabbar is bit easier in android Copy and download the code below and try it.... Basic tabbar tutorials see here... import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.TabHost; import android.widget.TabHost.TabSpec; import android.widget.TabWidget; import android.widget.TextView; import android.app.TabActivity; import android.content.Intent; public class MainActivity extends TabActivity { TabWidget tw; TabHost tabHost; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /** TabHost will have Tabs */ tabHost = (TabHost)findViewById(android.R.id.tabhost); TabSpec firstTabSpec = tabHost.newTabSpec("tab_id1"); TabSpec secondTabSpec = tabHost.newTabSpec("tab_id2"); TabSpec thirdTabSpec = tabHost.newTabSpec("tab_id3"); ...

Using TabHost to create a simple Tabbar application - An Android Example

For creating a tabbar application first create a tabhost object to create tabs In activity_main.xml we create TabHost and specify a layout where we are going to insert the tabs. Copy and download the code and try it yourself.... Now we are going to create three tabs. Lets us now first make the xml for it activity_main.xml : TabHost provided flexibility of managing data in different views by providing tabbed interface(compared to TabLayout). TabHost basically a container, where you need to put tab widget, which will host tabbed interface and FrameLayout, within which the different views are presented. TabHost ( main container of tab view ) TabWidget ( used to navigate between tabs ) FrameLayout ( for tab content ) <TabHost xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:l...