本来是用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。。
后面不知道怎么实现,写不下去了。。
哥,你不觉得是自己跟自己找事吗? 都是混口饭吃,何必把自己弄那么累,想开点用tabhost吧,人家天生就是干这个事情的。
这个就是使用BUTTON来实现tab效果的,你可以参考下,希望能帮助你....