km4gedan 2016-03-27 08:40 采纳率: 58.3%
浏览 1461
已采纳

andriod TabHost问题

package xx.com.test;

import android.app.ActivityManager;
import android.app.LocalActivityManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.R.string;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TabHost;

import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;

public class MainActivity extends AppCompatActivity {
private TabHost th;
private Intent soft;
private Intent money;
private Intent bill;
private Intent me;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    soft = new Intent(MainActivity.this, SoftyActivity.class);
    money = new Intent(MainActivity.this, MoneyActivity.class);
    bill = new Intent(MainActivity.this, BillActivity.class);
    me = new Intent(MainActivity.this, MeActivity.class);
    setContentView(R.layout.activity_main);
    th = (TabHost) findViewById(R.id.tabHost);
    th.setup();
    th.addTab(buildTagSpec("tab_soft",
            R.string.soft, R.drawable.shezhi, soft));
    th.addTab(buildTagSpec("tab_money",
            R.string.money, R.drawable.shezhi, money));
    th.addTab(buildTagSpec("tab_bill",
            R.string.bill, R.drawable.shezhi, bill));
    th.addTab(buildTagSpec("tab_me",
            R.string.me, R.drawable.shezhi, me));

}

private TabHost.TabSpec buildTagSpec(String tagName, int tagLable,
                                     int icon, Intent content) {
    return  th.newTabSpec(tagName)
            .setIndicator(getResources().getString(tagLable),
                    getResources().getDrawable(icon, null)).setContent(content);
}

}

图片说明

  • 写回答

2条回答 默认 最新

  • km4gedan 2016-03-31 08:53
    关注

    其实是这样的,tabhost 加载intent 就是要用localactivitymanager 搞一下。但是这个包已经弃用了....
    搞球不明白

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看