TabHost.setOnTabChangedListener在Nougat中不起作用

时间:2018-03-04 13:28:01

标签: android android-tabhost

我正在使用以下代码进行标签活动`

   public class ControlTab_Activity extends TabActivity implements OnTabChangeListener
{
public static TabHost mTabHst;

Intent myintent=getIntent();
        int val=myintent.getIntExtra("FromLogout", 0);
        //  if(BaseActivity.gmailactivityflag == 0)
            Resources res = getResources();
            //      try
            //      {
            intent1= new Intent(this,HomeActivity.class);
            intent2 = new Intent(this,MyCartActivity.class);
            intent3 = new Intent(this,ReorderActivity.class);
            intent4 = new Intent(this,TrackActivity.class);
            intent5 = new Intent(this,MyAccountActivity.class);
            intent5.putExtra("FromLogout", val);
            mTabHst = getTabHost();

            mTabHst.addTab(mTabHst.newTabSpec("Home")
                    .setIndicator("",res.getDrawable(R.drawable.selector_home_tab))
                    .setContent(intent1));

            mTabHst.addTab(mTabHst.newTabSpec("My Cart")
                    .setIndicator("",res.getDrawable(R.drawable.selector_cart_tab))
                    .setContent(intent2));

            mTabHst.addTab(mTabHst.newTabSpec("Reorder")
                    .setIndicator("",res.getDrawable(R.drawable.selector_recorder_tab))
                    .setContent(intent3));

            mTabHst.addTab(mTabHst.newTabSpec("Track")
                    .setIndicator("",res.getDrawable(R.drawable.selector_track_tab))
                    .setContent(intent4));


            mTabHst.addTab(mTabHst.newTabSpec("My Account")
                    .setIndicator("",res.getDrawable(R.drawable.selector_account_tab))
                    .setContent(intent5));

            mTabHst.setOnTabChangedListener((OnTabChangeListener) this);

}

` 上面的代码工作正常直到Marshmello但是当Nougat上运行代码时,SetOnTabChangeListener的onTabChange方法没有得到调用。我没有得到什么问题

0 个答案:

没有答案