Add a "footer" in a TabActivity

746 views
Skip to first unread message

Tom

unread,
Jun 15, 2009, 9:59:26 AM6/15/09
to Android Developers
Hi,

I created a TabActivity with contains 3 tabs. Each tab's content sets
different Intents.

I would like to add a "footer" wich will appear on each tab. So I get
TabActivity's FrameLayout and add it my footer view.

Is it possbile to define where place the footer (with an attribute
like AT_BOTTOM)?
So contentTab dimensions are calculated according to this footer.

(I hope my question is clear).

Here are some of my codes :

public class Temp extends TabActivity{

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final TabHost tabHost = getTabHost();

// First tab
TabHost.TabSpec userTab = tabHost.newTabSpec();
secTab.setIndicator(this.getString("Activity2"));
secTab.setContent(new Intent(this,Activity2.class));

// Second tab
TabHost.TabSpec secTab = tabHost.newTabSpec();
secTab.setIndicator(this.getString("Activity2"));
secTab.setContent(new Intent(this,Activity2.class));

// Third tab
TabHost.TabSpec thirdTab = tabHost.newTabSpec();
thirdTab.setIndicator(this.getString("Activity3"));
thirdTab.setContent(new Intent(this,Activity3.class));

// Footer View
FooterView footer = new FooterView(this);
// Add it to the frameLayout
tabHost.getTabContentView().addView(footer);
}
}

Thanks
Best regards
Tom

nEx.Software

unread,
Jun 15, 2009, 1:37:58 PM6/15/09
to Android Developers
So the footer is the same for all tabs?
In that case, I would set for the TabActivity a custom layout that
contains the footer.

Something like this:

<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"
android:padding="1dip">
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="0" />
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="0dip"
android:layout_weight="1"/>
<ImageView android:id="@+id/Logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:src="@drawable/
nexsoftware" android:background="#FF000000"
android:scaleType="fitCenter" />
</LinearLayout>
</TabHost>

Tom

unread,
Jun 16, 2009, 5:17:23 AM6/16/09
to Android Developers
All right.
Exactly what I was looking for.

Thanks
Tom

Tom

unread,
Jun 18, 2009, 9:32:02 AM6/18/09
to Android Developers
In addition,

is-it possible to remove the footer for a specified tab?

best regards
Tom
Reply all
Reply to author
Forward
0 new messages