Update tabs

This commit is contained in:
Victor Shcherb 2011-10-16 23:36:19 +02:00
parent b25b0dc003
commit 53766b39ea
2 changed files with 23 additions and 6 deletions

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/TabImage"
/>

View file

@ -25,6 +25,7 @@ import android.view.Window;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TabHost; import android.widget.TabHost;
import android.widget.TabHost.TabSpec; import android.widget.TabHost.TabSpec;
@ -70,6 +71,13 @@ public class SearchActivity extends TabActivity {
public void locationUpdate(LatLon l); public void locationUpdate(LatLon l);
} }
private View getTabIndicator(int imageId){
View r = getLayoutInflater().inflate(R.layout.search_main_tab_header, getTabHost(), false);
((ImageView)r.findViewById(R.id.TabImage)).setImageResource(imageId);
return r;
}
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -90,17 +98,20 @@ public class SearchActivity extends TabActivity {
TabHost host = getTabHost(); TabHost host = getTabHost();
host.addTab(host.newTabSpec("Search_POI").setIndicator(getString(R.string.poi)).setContent(new Intent(this, SearchPoiFilterActivity.class))); //$NON-NLS-1$ host.addTab(host.newTabSpec("Search_POI").setIndicator(getTabIndicator(R.drawable.tab_search_poi_icon)).
setContent(new Intent(this, SearchPoiFilterActivity.class))); //$NON-NLS-1$
addressSpec = host.newTabSpec("Search_Address").
setIndicator(getTabIndicator(R.drawable.tab_search_address_icon));
addressSpec = host.newTabSpec("Search_Address").setIndicator(getString(R.string.address));
setAddressSpecContent(); setAddressSpecContent();
host.addTab(addressSpec); host.addTab(addressSpec);
host.addTab(host.newTabSpec("Search_Location").setIndicator(getString(R.string.search_tabs_location)).setContent(createIntent(NavigatePointActivity.class))); //$NON-NLS-1$ host.addTab(host.newTabSpec("Search_Location").setIndicator(getTabIndicator(R.drawable.tab_search_location_icon)).setContent(createIntent(NavigatePointActivity.class))); //$NON-NLS-1$
TabSpec transportTab = host.newTabSpec("Search_Transport").setIndicator(getString(R.string.transport)).setContent(createIntent(SearchTransportActivity.class)); TabSpec transportTab = host.newTabSpec("Search_Transport").setIndicator(getTabIndicator(R.drawable.tab_search_transport_icon)).setContent(createIntent(SearchTransportActivity.class));
host.addTab(transportTab); //$NON-NLS-1$ host.addTab(transportTab); //$NON-NLS-1$
host.addTab(host.newTabSpec("Search_Favorites").setIndicator(getString(R.string.favorite)).setContent(createIntent(FavouritesListActivity.class))); //$NON-NLS-1$ host.addTab(host.newTabSpec("Search_Favorites").setIndicator(getTabIndicator(R.drawable.tab_search_favorites_icon)).setContent(createIntent(FavouritesListActivity.class))); //$NON-NLS-1$
host.addTab(host.newTabSpec("Search_History").setIndicator(getString(R.string.history)).setContent(createIntent(SearchHistoryActivity.class))); //$NON-NLS-1$ host.addTab(host.newTabSpec("Search_History").setIndicator(getTabIndicator(R.drawable.tab_search_history_icon)).setContent(createIntent(SearchHistoryActivity.class))); //$NON-NLS-1$
host.setCurrentTab(POI_TAB_INDEX); host.setCurrentTab(POI_TAB_INDEX);