Android 标签内容在初始化后不会更改,最新按下的标签仍保留

Android 标签内容在初始化后不会更改,最新按下的标签仍保留,android,tabs,android-listview,android-tabhost,android-tabactivity,Android,Tabs,Android Listview,Android Tabhost,Android Tabactivity,我使用此代码创建n个选项卡: TabHost tabs = (TabHost)findViewById(R.id.tabhost); tabs.setup(mLocalActivityManager); StateListDrawable[] drawables = new StateListDrawable[hotel.categoryArray.length]; for (int i = 0; i < hotel.categoryArray.le

我使用此代码创建n个选项卡:

TabHost tabs = (TabHost)findViewById(R.id.tabhost); 
     tabs.setup(mLocalActivityManager); 

     StateListDrawable[] drawables  = new StateListDrawable[hotel.categoryArray.length];

     for (int i = 0; i < hotel.categoryArray.length; i++){
         TabSpec spec1 = tabs.newTabSpec(hotel.categoryArray[i]);
         Intent intent = new Intent(this, ListViewActivity.class);
         Bundle b = new Bundle();
         b.putParcelableArrayList("Businesses", createArray(hotel.categoryArray[i], hotel.explore));
         intent.putExtras(b);
         spec1.setContent(intent); 
         TextView tab1 = new TextView(this);
         tab1.setText(hotel.categoryArray[i]);
         tab1.setGravity(android.view.Gravity.CENTER);
         tab1.setTextSize(14.0f);
         tab1.setTextColor(text);
         drawables[i] = new StateListDrawable();
         drawables[i].addState(selected, new ColorDrawable(selectedColor));
         drawables[i].addState(unselected, new ColorDrawable(defaultColor));
         tab1.setBackgroundDrawable(drawables[i]);
         spec1.setIndicator(tab1);
         tabs.addTab(spec1);
     }

     tabs.setCurrentTab(0);
TabHost tabs=(TabHost)findviewbyd(R.id.TabHost);
tabs.设置(mLocalActivityManager);
StateListDrawable[]drawables=新StateListDrawable[hotel.categoryArray.length];
对于(int i=0;i
这是我的ListViewActivity。它获取对象的ArrayList,并使用我的自定义MyCustomBaseAdapter填充该列表,该列表似乎工作正常

 @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.list);

         Bundle bundle = this.getIntent().getExtras();
         ArrayList<Business> business = null;
         if(bundle!=null) {
             business = bundle.getParcelableArrayList("Businesses");
         }

         final ListView lv1 = getListView();
         lv1.setAdapter(new MyCustomBaseAdapter(this, business));

         lv1.setOnItemClickListener(new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> a, View v, int position, long id) { 
           Object o = lv1.getItemAtPosition(position);
           Business fullObject = (Business)o;
           Toast.makeText(ListViewActivity.this, "You have chosen: " + " " + fullObject.name, Toast.LENGTH_LONG).show();
          }  
         });
 }
@覆盖
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.list);
Bundle Bundle=this.getIntent().getExtras();
ArrayList业务=null;
if(bundle!=null){
业务=bundle.getParcelableArrayList(“业务”);
}
最终ListView lv1=getListView();
lv1.setAdapter(新的MyCustomBaseAdapter(this,business));
lv1.setOnItemClickListener(新的OnItemClickListener(){
@凌驾
public void onItemClick(适配器视图a、视图v、内部位置、长id){
对象o=lv1.getItemAtPosition(位置);
业务fullObject=(业务)o;
Toast.makeText(ListViewActivity.this,“您已选择:”+“”+fullObject.name,Toast.LENGTH\u LONG.show();
}  
});
}
问题是,它填充选项卡,按每个新选项卡填充字段都很好,但是当您返回到上一个选项卡时,它不会更改回原来的选项卡,内容仍然保留。它也以一种奇怪的方式进行,它不会从第二个标签切换到第一个标签,它会在第三个标签到第二个标签之间切换良好,如果您切换到第四个标签,它的内容将保留在所有标签中

我应该在哪里寻找问题或替代解决方案,让一个类填充列表并具有“临时”选项卡