本来是用tabHost的,不过这玩意的标签样式和颜色好像很难控制,所以改用button做tab,布局文件是这样的:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical" android:paddingLeft="@dimen/global_left_margin" android:paddingRight="@dimen/global_right_margin" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:gravity="center" android:id="@+id/funcList" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/global_top_margin"
android:background="#36648B">
<Button android:id="@+id/softwareManageButton" android:layout_width="0.0px" android:layout_height="wrap_content" android:text="已安装" android:layout_weight="1.0" style="@style/TopTypeLeft.Button" />
<Button android:id="@+id/updateSoftwareButton" android:layout_width="0.0px" android:layout_height="wrap_content" android:text="可升级" android:layout_weight="1.0" style="@style/TopTypeMiddle.Button" />
<Button android:id="@+id/taskListButton" android:layout_width="0.0px" android:layout_height="wrap_content" android:text="下载任务" android:layout_weight="1.0" style="@style/TopTypeRight.Button" />
</LinearLayout>
<FrameLayout android:id="@+id/contentFrame" android:layout_width="fill_parent" android:layout_height="0.0px" android:layout_weight="1.0" />
</LinearLayout>
但是,如何实现点击按钮动态加载不同的内容呢,如listView等,有没有类似tabHost那种可以setContent(new Intent(this,SmActivity.class))的方法的?
final Button localButton1 = (Button)findViewById(R.id.softwareManageButton);
final Button localButton2 = (Button)findViewById(R.id.updateSoftwareButton);
final Button localButton3 = (Button)findViewById(R.id.taskListButton);
localButton1.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v)
{
localButton1.setSelected(true);
localButton2.setSelected(false);
localButton3.setSelected(false);
FrameLayout localFrameLayout = (FrameLayout)findViewById(R.id.contentFrame);
FrameLayout.LayoutParams localLayoutParams = new FrameLayout.LayoutParams(-1, -1);
localFrameLayout.addView。。
后面不知道怎么实现,写不下去了。。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical" android:paddingLeft="@dimen/global_left_margin" android:paddingRight="@dimen/global_right_margin" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:gravity="center" android:id="@+id/funcList" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/global_top_margin"
android:background="#36648B">
<Button android:id="@+id/softwareManageButton" android:layout_width="0.0px" android:layout_height="wrap_content" android:text="已安装" android:layout_weight="1.0" style="@style/TopTypeLeft.Button" />
<Button android:id="@+id/updateSoftwareButton" android:layout_width="0.0px" android:layout_height="wrap_content" android:text="可升级" android:layout_weight="1.0" style="@style/TopTypeMiddle.Button" />
<Button android:id="@+id/taskListButton" android:layout_width="0.0px" android:layout_height="wrap_content" android:text="下载任务" android:layout_weight="1.0" style="@style/TopTypeRight.Button" />
</LinearLayout>
<FrameLayout android:id="@+id/contentFrame" android:layout_width="fill_parent" android:layout_height="0.0px" android:layout_weight="1.0" />
</LinearLayout>
但是,如何实现点击按钮动态加载不同的内容呢,如listView等,有没有类似tabHost那种可以setContent(new Intent(this,SmActivity.class))的方法的?
final Button localButton1 = (Button)findViewById(R.id.softwareManageButton);
final Button localButton2 = (Button)findViewById(R.id.updateSoftwareButton);
final Button localButton3 = (Button)findViewById(R.id.taskListButton);
localButton1.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v)
{
localButton1.setSelected(true);
localButton2.setSelected(false);
localButton3.setSelected(false);
FrameLayout localFrameLayout = (FrameLayout)findViewById(R.id.contentFrame);
FrameLayout.LayoutParams localLayoutParams = new FrameLayout.LayoutParams(-1, -1);
localFrameLayout.addView。。
后面不知道怎么实现,写不下去了。。
解决方案 »
- framebuffer 提取图形数据 android工程
- 菜鸟求助:基于iMX51开发板上uboot移植与fastboot的实现问题
- 关于Eclipse开发Android添加类问题【菜鸟】
- 我应该怎么选择比较好?
- Iphone到底魅力何在?竟引得无数英雄折腰?求详解?是品牌,是技术,是文化?
- 关于JNI 的问题(所有都编译好运行后提示找不到方法)
- 关于闹钟和notification的问题
- 急!安卓设备中SD卡在windows下写100M以上的数据出现参数错误?
- 又来问问题了。。。关于ObjectInputStream!
- AndroidQ 无法获取剪切板的内容。这个要怎么办
- 请问jni下如何画位图
- 基于WikiAPI的手机客户端开发
哥,你不觉得是自己跟自己找事吗? 都是混口饭吃,何必把自己弄那么累,想开点用tabhost吧,人家天生就是干这个事情的。
这个就是使用BUTTON来实现tab效果的,你可以参考下,希望能帮助你....