我先是在mainActivity中定义了一个用于做呈现的tabhost,里面的tab通过intent来加载用NormalListActivity实现的listview,现在需要在mainActivity中根据用户输入的list来放到NormalListActivity中的listview中显示出来,不知道该如何传递这些数据,求救于各位大虾。我在tabhost中加载listview的方法如下,这段代码没问题:
TabHost tabhost = getTabHost();
title = CreateTabTitle();
for(int i=0;i < title.length;i++){
LinearLayout view = (LinearLayout) getLayoutInflater().inflate(R.layout.tabwiget, null);
((TextView)view.findViewById(R.id.tv_title)).setText(title[i]);
tabhost.addTab(tabhost.newTabSpec(title[i]).setIndicator(view)
.setContent(new Intent(mainActivity.this, NormalListActivity.class)));
}
TabHost tabhost = getTabHost();
title = CreateTabTitle();
for(int i=0;i < title.length;i++){
LinearLayout view = (LinearLayout) getLayoutInflater().inflate(R.layout.tabwiget, null);
((TextView)view.findViewById(R.id.tv_title)).setText(title[i]);
tabhost.addTab(tabhost.newTabSpec(title[i]).setIndicator(view)
.setContent(new Intent(mainActivity.this, NormalListActivity.class)));
}
tabhost.addTab(tabhost.newTabSpec(title[i]).setIndicator(view)
.setContent(new Intent(mainActivity.this, NormalListActivity.class)));改为:
Intent tabIntent = new Intent(mainActivity.this, NormalListActivity.class);
Bundle bundle = new Bundle();
bundle.putString("list", list); //假设你的list是字符串类型
tabIntent.putExtras(bundle);tabhost.addTab(tabhost.newTabSpec(title[i]).setIndicator(view).setContent(tabIntent));
然后在NormalListActivity里面增加Intent intent = getIntent();
Bundle bundle = intent.getExtras();
String getList = bundle.getString("list");