km4gedan
km4gedan
2016-03-27 08:40
采纳率: 58.3%
浏览 1.5k

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
    km4gedan 2016-03-31 08:53
    已采纳

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

    点赞 评论
  • lxk_1993
    103style 2016-03-28 02:16

    Did you forgrt to call "public void step(...)"

    点赞 评论

相关推荐