我有 4 个选项卡的 tabview,我正在使用 TabHost 显示我的应用程序的选项卡。每个选项卡都由另一个从 ListActivity 扩展的类填充,这是代码
public class TabbedActivity extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab_layout);
TabHost tabHost = getTabHost();
// Tab for Catalog
TabSpec catalogspec = tabHost.newTabSpec("Catalog");
catalogspec.setIndicator("Complete Catalog Fall 2012", getResources().getDrawable(R.drawable.ic_catalog));
Intent catalogIntent = new Intent(this, Category.class);
catalogspec.setContent(catalogIntent);
// Adding all TabSpec to TabHost
tabHost.addTab(catalogspec); // Adding catalog tab
}
这是另一个意图的代码
public class Category extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_of_data);
Categories = new ArrayList<String>();
fillListCategories();
myListItems = new ArrayList<String>();
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Categories);
this.setListAdapter(adapter);
}}
在 Listview 有项目列表,我的观点是如何设置 Onclick 在同一个选项卡中打开另一个“ListActivity”?!