Activity跳转到 TabActivity的子页面

。。。。。。随手记下,这个东西用到的并不是太多


还用上次写的TabActivity那个demo来说吧点击打开链接


在TabActivity 中的oncreate() 中添加 广播,代码如下:


//注册广播
        IntentFilter filter = new IntentFilter();
        filter.addAction("com.example.one");
        filter.addAction("com.example.two");
        filter.addAction("com.example.three");
        filter.addAction("com.example.four");
        TestRevice revice = new TestRevice();
        registerReceiver(revice, filter);

加个内部类


class TestRevice extends BroadcastReceiver {

        @Override
        public void onReceive(Context context, Intent intent) {
            //实现跳转
            if (intent.getAction().equalsIgnoreCase("com.example.one")){
                tabHost.setCurrentTabByTag("home");         
            }
            if (intent.getAction().equalsIgnoreCase("com.example.two")){
                tabHost.setCurrentTabByTag("contrl");
            }
            if (intent.getAction().equalsIgnoreCase("com.example.three")){
                tabHost.setCurrentTabByTag("suiyi");
            }
            if (intent.getAction().equalsIgnoreCase("com.example.four")){
                tabHost.setCurrentTabByTag("set");
            }

        }

    }


最后在其他Activity 跳转的时候,发广播跳转即可


// 发送广播
				Intent intent = new Intent("com.example.three");
				sendBroadcast(intent);





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值