80,351
社区成员
发帖
与我相关
我的任务
分享
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
tools:context=".RadioActivity"
android:textColor="#000000" >
<TabHost
android:id="@+id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textColor="#000000">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:textColor="#000000" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
android:textColor="#000000">
for(int i = 0; i < tabWidge.getChildCount(); i++) {
final TextView tv = (TextView) tabWidge.getChildAt(i).findViewById(android.R.id.title);
tv.setTextColor(Color.WHITE);
tv.setTextSize(18);
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/indicator_bg"
android:gravity="center" >
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:gravity="center"
android:textAppearance="@android:style/TextAppearance.Medium"
android:textColor="#FFFFE7" />
</LinearLayout>
music_explorer.xml
<?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:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0.0dip"
android:layout_weight="1.0" />
</LinearLayout>
</TabHost>
activity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.music_explorer);
li=getLayoutInflater();
initTabs();
}
private void initTabs(){
TabHost th=getTabHost();
th.setOnTabChangedListener(this);
TabSpec ts = null;
int count = 4;
if(artist_key.length()>0){
count = 2;
}
for(int i=0;i<count;i++){
ts=th.newTabSpec(tags[i]);
View view=li.inflate(R.layout.indicator, null);
TextView tv=(TextView) view.findViewById(R.id.textView);
tv.setText(getString(tabsResources[i]));
ts.setIndicator(view);
ts.setContent(this);
th.addTab(ts);
}
}