原谅我简单的问题,因为我是新来的android。 :)Android TextView文本没有显示在标签内?
为什么textview的text属性不显示在此选项卡内?
屏幕:Here
这里是我的代码..
MapTab2.java
package com.test.maptab2;
import android.app.TabActivity;
import android.os.Bundle;
import android.widget.TabHost;
public class MapTab2 extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost.TabSpec spec;
spec = getTabHost().newTabSpec("tab1");
spec.setContent(R.id.mapstub);
spec.setIndicator("Map");
getTabHost().addTab(spec);
spec = getTabHost().newTabSpec("tab2");
spec.setContent(R.id.detailstub);
spec.setIndicator("Detail");
getTabHost().addTab(spec);
getTabHost().setCurrentTab(0);
}
}
main.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:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- Tab-switch panel -->
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<!-- Tab contents -->
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- Map here -->
<TextView android:id="@+id/mapstub"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="map"/>
<!-- Other stuff -->
<TextView android:id="@+id/detailstub"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="detail"/>
</FrameLayout>
</LinearLayout>
</TabHost>
我试图建立我的方式达到在选项卡中显示地图。最好先理解基础知识,我想。 :')
谢谢,将所有内容设置为wrap_content使文本显示。 – Ephemeros 2012-02-05 14:17:28