2 km4gedan km4gedan 于 2016.03.27 16:40 提问

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);
}

}

图片说明

3个回答

km4gedan
km4gedan   2016.03.31 16:53
已采纳

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

lxk_1993
lxk_1993   Rxr 2016.03.28 10:16

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

CSDNXIAON
CSDNXIAON   2016.03.30 11:27

TabHost问题
Andriod TabHost的使用TabHost
Android: TabHost的问题
----------------------同志你好,我是CSDN问答机器人小N,奉组织之命为你提供参考答案,编程尚未成功,同志仍需努力!

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!