写了一个TabActivity,想要在每个tab里面都用个ListView从数据库添加所要的数据。通过TabHost的实例化对象tabhost.setcontent(intent)方法连接ListView的Activity,但想通过intent传递个数据过去,用来辨别要显示哪些数据。
用了tabhost.setContent(intent.putExtras(cn.edu.nuc.lookTab.this.notSentBundle),但报错了。(notSentBundle是我创建的用来传数据的Bundle类对象)
求指点!!

解决方案 »

  1.   

    是什么异常,是不是setup(LocalActivityManager activityGroup),要你去建activityGroup?
      

  2.   

    不是,不过现在已经解决啦~不过还有点小问题。
    我创建了三个Bundle的对象,要分别在三个Tab里面使用。但传到另一个Activity里面后,头一个notSentBundle传过去的数据是正确的,就是notSent。但后两个传过去的数据都是第三个draftboxBundle的数据draftbox。请问这是怎么回事啊?
    notSentBundle = new Bundle();
    notSentBundle.putString("text", "notSent");
    sentBundle = new Bundle();
    sentBundle.putString("text", "sent");
    draftboxBundle = new Bundle();
    draftboxBundle.putString("text", "draftbox");lookTabHost.addTab(lookTabHost.newTabSpec("One")
    .setIndicator("", getResources().getDrawable(R.drawable.contact_photo))
    .setContent(R.id.firstTabID)
    .setContent(intent)
    .setContent(intent.putExtras(cn.edu.nuc.lookTab.this.notSentBundle))
    );

    lookTabHost.addTab(lookTabHost.newTabSpec("Two")
    .setIndicator("", getResources().getDrawable(R.drawable.contact_photo))
    .setContent(R.id.secondTabID)
    .setContent(intent)
    .setContent(intent.putExtras(cn.edu.nuc.lookTab.this.sentBundle))
    );

    lookTabHost.addTab(lookTabHost.newTabSpec("Three")
    .setIndicator("", getResources().getDrawable(R.drawable.contact_photo))
    .setContent(R.id.thirdTabID)
    .setContent(intent)
    .setContent(intent.putExtras(cn.edu.nuc.lookTab.this.draftboxBundle))
    );
      

  3.   

    你怎么每一段都有一个.setContent(intent)?
    我的一些例子:
     TabHost tabhost = (TabHost) findViewById(android.R.id.tabhost);
            tabhost.setup(this.getLocalActivityManager());
            Intent intent1 = new Intent(this,Second.class);
            Bundle bundle1 = new Bundle();
            bundle1.putStringArray("string", strings1);
            bundle1.putFloatArray("values", values1);
            intent1.putExtra("bundle",bundle1);
            
            Intent intent2 = new Intent(this,Second.class);
            Bundle bundle2 = new Bundle();
            bundle2.putStringArray("string", strings2);
            bundle2.putFloatArray("values", values2);
            intent2.putExtra("bundle",bundle2);
            
            Intent intent3 = new Intent(this,Second.class);
            Bundle bundle3 = new Bundle();
            bundle3.putStringArray("string", strings3);
            bundle3.putFloatArray("values", values3);
            intent3.putExtra("bundle",bundle3);
            
            tabhost.addTab(tabhost.newTabSpec("tab1").setIndicator("spec1").setContent(intent1));
            tabhost.addTab(tabhost.newTabSpec("tab2").setIndicator("spec2").setContent(intent2));
            tabhost.addTab(tabhost.newTabSpec("tab3").setIndicator("spec3").setContent(intent3));
      

  4.   

    哦哦~我本来想的三个tab都要用同一个Activity,所以就用了一个intent……现在换成用三个就没问题啦!!谢谢指点!
    另外还有个问题问一问哈、、我ListView的Activity里面,List是用的自己写的BaseAdapter的子类。里面写了三个Text和一个ToggleButton(请原谅我这个新手不会往这里面加图片……)。但现在只有ToggleButton有焦点,List没焦点。网上看资料说在布局文件里把ToggleButton设置为没焦点的就可以了。可是怎么设置了?或者还有其他办法?