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条)

报告相同问题?