Skip to content

Instantly share code, notes, and snippets.

@icespider
Forked from JakeWharton/AndroidManifest.xml
Created August 25, 2013 14:57
Show Gist options
  • Save icespider/6334271 to your computer and use it in GitHub Desktop.
Save icespider/6334271 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.actionbarsherlock.sample.stylenativetabs"
android:versionCode="1"
android:versionName="1.0.0">
<uses-sdk android:minSdkVersion="4" />
<application android:label="Styled Native Tabs" android:theme="@style/Theme.Sherlock">
<activity android:name=".NativeTabActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<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">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="48dp"
/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
</LinearLayout>
</TabHost>
package com.actionbarsherlock.sample.stylenativetabs;
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.TabHost.TabContentFactory;
import android.widget.TabHost.TabSpec;
public class NativeTabActivity extends Activity {
private TabHost mTabHost;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mTabHost = (TabHost)findViewById(android.R.id.tabhost);
mTabHost.setup();
addTab(new TextView(this), "Tab 1");
addTab(new TextView(this), "Tab 2");
addTab(new TextView(this), "Tab 3");
}
private void addTab(final View content, final String title) {
View tabView = LayoutInflater.from(this).inflate(R.layout.abs__action_bar_tab_layout, null);
TextView tv = (TextView) tabView.findViewById(R.id.abs__tab);
tv.setText(title);
TabSpec setContent = mTabHost.newTabSpec(title).setIndicator(tabView).setContent(new TabContentFactory() {
public View createTabContent(String tag) {
return content;
}
});
mTabHost.addTab(setContent);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment