-
-
Save icespider/6334271 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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