i have tabview with 4 tabs and i am using TabHost to display tabs my application.
every tab is filled by another class extends from ListActivity and here is the code
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
}
and this the code at the other intent
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);
}}
at the Listview there is list of items ,, my Point is how to set the Onclick to open another “ListActivity” in the same Tab ?!!
In your Category class, add an onClickListener like so:
ScreenTwo.java would look like the category class with the ListAdapter but with the information that was passed through the intent: