Frage

enter image description here

I want to change Font in Tab that i have created in my android app.

here's my xml file:

<com.markupartist.android.widget.ActionBar
    android:id="@+id/actionbar"
    style="@style/ActionBar" />

<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"
    android:background="@android:color/white" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="fill_vertical"
        android:orientation="vertical" >

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/darker_gray"
            android:orientation="horizontal"
            android:paddingTop="0dp"
            android:tabStripEnabled="true" />

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp" />
    </LinearLayout>
</TabHost> 

and here's my activity :

public class Home_Activity extends TabActivity {

private static final int DIALOG_REALLY_EXIT_ID = 0;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home);

    final ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
    actionBar.setTitle(getString(R.string.app_name));

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, "I've Been Using");
    intent.putExtra(Intent.EXTRA_TEXT, "BikeDSS Application by: Chocholuis");

    final Action shareAction = new IntentAction(this, Intent.createChooser(
            intent, "Share BikeDSS"), R.drawable.icon_share);
    actionBar.addAction(shareAction);

    Action searchAction = new IntentAction(this, new Intent(this,
            search_activity.class), R.drawable.icon_search);
    actionBar.addAction(searchAction);

    Resources res = getResources(); // Resource object to get Drawables
    TabHost tabHost = getTabHost(); // The activity TabHost
    TabHost.TabSpec spec; // Reusable 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, Tab_Bike_Activity.class);

    // Initialize a TabSpec for each tab and add it to the TabHost
    spec = tabHost.newTabSpec("bike")
            .setIndicator("Bike", res.getDrawable(R.drawable.sepeda))
            .setContent(intent);
    tabHost.addTab(spec);

    // Do the same for the other tabs
    intent = new Intent().setClass(this, Tab_Brand_ListView_Activity.class);
    spec = tabHost.newTabSpec("information")
            .setIndicator("Information", res.getDrawable(R.drawable.info))
            .setContent(intent);
    tabHost.addTab(spec);

    intent = new Intent().setClass(this,
            Tab_Shop_Repair_ListView_Activity.class);
    spec = tabHost
            .newTabSpec("repair")
            .setIndicator("Shop and Bicycle Repair",
                    res.getDrawable(R.drawable.bengkel)).setContent(intent);
    tabHost.addTab(spec);

    tabHost.setCurrentTab(0);

} 

is that possible i can change the font? i really need help. thanks

War es hilfreich?

Lösung

You have to create your own tablayout. See this link for a Tutorial on tabhost customization : http://ondrejcermak.info/en/programovani/custom-tabs-in-android-tutorial/.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top