我是android的新手,所以我需要帮助。我想知道如何添加标题(我自己用xml制作)和它下面的标签。因此,当我的应用程序从头部开始,并且在我的标题下方将显示标签
需要指导我会很感激。
header.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layoutHeader"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_alignParentTop="true"
android:background="#010000"
android:orientation="vertical" >
<!-- Logo -->
<ImageView
android:src="@drawable/logo"
android:id="@+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dip"
android:contentDescription="@string/desc" />
<!-- Plus Button -->
<ImageButton
android:src="@drawable/plus"
android:id="@+id/btnAddSite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dip"
android:background="@null"
android:contentDescription="@string/desc" />
</RelativeLayout>
我需要下面的标签
package com.lab.rssnewsreader;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
@SuppressWarnings("deprecation")
public class MainActivity extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Resources res= getResources();
TabHost tabhost =getTabHost();
TabSpec pakistanspec= tabhost.newTabSpec("pakistan");
pakistanspec.setIndicator("",res.getDrawable(R.drawable.pakistan) );
Intent intent =new Intent(this, Pakistan_News.class);
pakistanspec.setContent(intent);
TabSpec worldspec= tabhost.newTabSpec("world");
worldspec.setIndicator("",res.getDrawable(R.drawable.world) );
Intent intent2 =new Intent(this, World_News.class);
worldspec.setContent(intent2);
TabSpec favspec= tabhost.newTabSpec("favourite");
favspec.setIndicator("",res.getDrawable(R.drawable.fav) );
Intent intent3 =new Intent(this, Favourite_News.class);
favspec.setContent(intent3);
tabhost.addTab(pakistanspec);
tabhost.addTab(worldspec);
tabhost.addTab(favspec);
tabhost.setBackgroundColor(Color.WHITE);
tabhost.getTabWidget().setBackgroundColor(Color.GRAY);
}
}