I have a problem presenting the tab. I need to show the tab a lot of navigation. For instance. On the first tab, called "Sales," it displays the entire sales route. If the user clicks one route, he needs to go to the list of retailers, for example, put him on the first tab. Many pages (views) are available.
From my window, only the tab is displayed in the first view, which means that when she loads the tab, she showed me a list of sales routes with a tab view. When I click on the sales route, it displays the retailer, but not displayed as tabs.
This is my code: tabview.xml
<?xml version="1.0" encoding="utf-8"?> <TabHost android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost"> <LinearLayout android:id="@+id/LinearLayout01" android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent"> <TabWidget android:id="@android:id/tabs" android:layout_height="wrap_content" android:layout_width="fill_parent"></TabWidget> <FrameLayout android:id="@android:id/tabcontent" android:layout_height="fill_parent" android:layout_width="fill_parent"></FrameLayout> </LinearLayout>
This is my mainActivity:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tabview); TabHost t = getTabHost(); TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost); TabSpec firstTabSpec = tabHost.newTabSpec("tid1"); TabSpec secondTabSpec = tabHost.newTabSpec("tid1"); TabSpec thirdTabSpec = tabHost.newTabSpec("tid1"); firstTabSpec.setIndicator("Sales").setContent(new Intent(this,SalesRouteActivity.class)); secondTabSpec.setIndicator("Admin").setContent(new Intent(this,SalesRoutesTab.class)); thirdTabSpec.setIndicator("Setting").setContent(new Intent(this,SalesRoutesTab.class)); tabHost.addTab(firstTabSpec); tabHost.addTab(secondTabSpec); tabHost.addTab(thirdTabSpec); }
This is my SalesRouteActivity;
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sales_routes); ArrayList<Object> routeList = getWmRoute(); ArrayList<String> routhPath = new ArrayList<String>(); for(int i = 0; i<routeList.size();i++){ routhPath.add(((WMRoute) routeList.get(i)).getDescription()); } ArrayAdapter ad = new ArrayAdapter(this,android.R.layout.simple_list_item_single_choice,routhPath); setListAdapter(ad); final ListView list=getListView(); list.setChoiceMode(ListView.CHOICE_MODE_SINGLE); list.setItemsCanFocus(true); list.setTextFilterEnabled(true); list.setItemChecked(positions,true); keyword = (String) list.getItemAtPosition(0); } @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add("OK"); menu.add("Cancel"); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case 0: Intent showContent = new Intent(getApplicationContext(),ListRetailerActivity.class); Bundle bundle = new Bundle(); bundle.putString("RouteName", keyword); showContent.putExtras(bundle); startActivity(showContent); return true; case 1: return true; default: return super.onOptionsItemSelected(item); } }
This is part of a ListRetailerActivity retailer;
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.retailer_list); Bundle bundle = this.getIntent().getExtras(); String routeName = bundle.getString("RouteName"); setTitle(routeName + " - List Retailer "); ArrayList<Object> routeList = getWmRoute(); // ArrayList<String> routhPath = new ArrayList<String>(); ArrayList<HashMap<String,String>> alist=new ArrayList<HashMap<String,String>>(); for(int i = 0; i<routeList.size();i++){ HashMap<String, String> map = new HashMap<String, String>(); map.put("RetailerCode", ((WMRoute) routeList.get(i)).getDescription()); map.put("RetailerName", ((WMRoute) routeList.get(i)).getBusinessUnit()); alist.add(map); } ListView list=getListView(); sd = new SimpleAdapter(this,alist,R.layout.retalier_rows,new String[]{"RetailerCode","RetailerName"},new int[]{R.id.retailerCode,R.id.retailerName}); list.setAdapter(sd); list.setChoiceMode(ListView.CHOICE_MODE_SINGLE); list.setSelected(true); list.setSelection(0); list.setTextFilterEnabled(true); list.setItemsCanFocus(true); list.setTextFilterEnabled(true); list.setItemChecked(positions,true); keyword = ((WMRoute) routeList.get(0)).getBusinessUnit(); //keyword = (String) list.getItemAtPosition(0); }
Here I have to show listActivity and TabActivity. How can we realize this?


All child actions should display a tab.
Please help me how to call another xml to navigate with tab view.
Thanks in advance.