Java 如何使Android中的tabbar看起来像XML中的iPhone tabbar
我想让Android的标签栏看起来像Android 这是我的密码: main.xmlJava 如何使Android中的tabbar看起来像XML中的iPhone tabbar,java,android,xml,android-layout,tabbar,Java,Android,Xml,Android Layout,Tabbar,我想让Android的标签栏看起来像Android 这是我的密码: main.xml <?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/tabhost"
android:orientation="vertical" >
<TabWidget
android:layout_width="fill_parent"
android:layout_height="40px"
android:id="@android:id/tabs"
android:layout_alignParentBottom="true"
></TabWidget>
</TabHost>
我需要做哪些更改才能使Tabbar正常工作?我还创建了其他类,如tab1.java、tab2.java等。@AdilSoomro谢谢!但是你能看看我写的代码并指出如何修改吗。这对我会有很大帮助的,只要我的2美分:不要这样做。用户出于不同的原因决定购买Android设备。他们不想要iPhone。因此,坚持默认的Android外观是完全可以的。“我知道,没有什么帮助,但请想一想。”我的一个朋友亨里克向我挑战,要我这么做,这只是为了知识。不会在真实场景中实现它。@henrik-有些人购买android和android是因为它们比iPhone便宜,而不是因为他们不想要iPhone LOL!!!
package com.saa;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class TabActivity extends android.app.TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TabHost tabHost=getTabHost();
Intent intent = new Intent();
TabSpec tabSpec= tabHost.newTabSpec("one");
tabSpec.setIndicator("One", getResources().getDrawable(R.drawable.ic_launcher));
intent.setClass(this, tab1.class);
tabSpec.setContent(intent);
tabHost.addTab(tabSpec);
tabSpec= tabHost.newTabSpec("two");
tabSpec.setIndicator("Two", getResources().getDrawable(R.drawable.ic_launcher));
intent = new Intent().setClass(this, tab2.class);
tabSpec.setContent(intent);
tabHost.addTab(tabSpec);
tabSpec= tabHost.newTabSpec("three");
tabSpec.setIndicator("Three", getResources().getDrawable(R.drawable.ic_launcher));
intent = new Intent().setClass(this, tab3.class);
tabSpec.setContent(intent);
tabHost.addTab(tabSpec);
tabSpec= tabHost.newTabSpec("four");
tabSpec.setIndicator("Four",getResources().getDrawable(R.drawable.ic_launcher));
intent = new Intent().setClass(this, tab4.class);
tabSpec.setContent(intent);
tabHost.addTab(tabSpec);
tabHost.setCurrentTab(0); // default tab
}
}