android下如何使每个标签页为一个单独的Activity 我今天第一次成功使用TabHost做出了标签页的效果 但是我发现 所有的标签页用的都是一个layout 如何能把没个标签页都变成主页那种单独的Activity 这样的话将来修改或添加菜单栏或者按钮时也会比较方便 我发现在这种界面下不同的标签页内如果都出现RadioGroup的话 几个标签界面就会重叠显示了...... 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 请看我的代码: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: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="fill_parent" android:padding="2dp" /> </LinearLayout></TabHost>Java代码:public class LaunchActivity extends TabActivity { /** Called when the activity is first created. */ public static TabHost tabHost; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tabHost = this.getTabHost(); TabHost.TabSpec spec; Intent intent; // 添加标签1 intent = new Intent().setClass(this, activity1.class); spec = tabHost.newTabSpec("标签1").setIndicator("标签1", null) .setContent(intent); tabHost.addTab(spec); // 添加标签2 intent = new Intent().setClass(this, activity2.class); spec = tabHost.newTabSpec("标签2").setIndicator("标签2", null) .setContent(intent); tabHost.addTab(spec); // 设置默认标签 tabHost.setCurrentTab(0); }} adb push是不是不支持中文名称的资源啊 Activity没有finish,切到别的界面再回来以后手势监听就不能用了? div的overflow属性在安卓2.3浏览器里面无效,怎么解决? Android4.0获取本机ip地址的问题 如何实现雨滴下雨的效果呢 求教android的解锁代码调试方法 大家帮帮忙~! 关于android-ndk jni开发的问题 高手帮忙啊 谢谢 SharedPreferences空指针问题! VSYNC 是在哪turn on的? 如何实现一键截图分享到多个sns平台 为啥我的button没有响应呢
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: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="fill_parent"
android:padding="2dp" />
</LinearLayout></TabHost>Java代码:
public class LaunchActivity extends TabActivity {
/** Called when the activity is first created. */
public static TabHost tabHost; @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tabHost = this.getTabHost();
TabHost.TabSpec spec;
Intent intent; // 添加标签1
intent = new Intent().setClass(this, activity1.class);
spec = tabHost.newTabSpec("标签1").setIndicator("标签1", null)
.setContent(intent);
tabHost.addTab(spec); // 添加标签2
intent = new Intent().setClass(this, activity2.class);
spec = tabHost.newTabSpec("标签2").setIndicator("标签2", null)
.setContent(intent);
tabHost.addTab(spec); // 设置默认标签
tabHost.setCurrentTab(0);
}
}