调试Android上的错误,在SetContentView崩溃

时间:2012-01-12 15:13:10

标签: android android-activity android-tabhost

   host.addTab(host.newTabSpec("Offers")
            .setIndicator("Offers", getResources().getDrawable(R.drawable.icon_light))
            .setContent(new Intent(this, List_Items.class)));




       host.addTab(host.newTabSpec("Settings")
            .setIndicator("Account", getResources().getDrawable(R.drawable.icon_wrench))
            .setContent(new Intent(this,Settings.class)));

       host.addTab(host.newTabSpec("Settings")
            .setIndicator("Settings", getResources().getDrawable(R.drawable.icon_user))
            .setContent(new Intent(this, Offer_Popup.class)));

      host.setCurrentTab(0);


   //////   receiving  in the activity

      BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {

            @Override
            public void onReceive(Context context, Intent intent) {
                // TODO Auto-generated method stub
                String action=intent.getAction();

                if (action.equals("popup"))
                {
                             Intent intent2= new Intent(context, Offer_Popup.class);
                    intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    Window window=getLocalActivityManager().startActivity("ID_2", intent2);
                    if (window != null) {

                        setContentView(window.getDecorView()); 
                    }    

从上面的代码中,接收器被触发,意图被启动。它在setContentview,RuntimeException崩溃,内容必须有一个Tabhost,其id属性为'android.R.id.tabhost'。应该如何修改代码?

0 个答案:

没有答案