use of android.widget.TabHost in project robolectric by robolectric.
the class ShadowTabHostTest method canGetCurrentTabTag.
@Test
public void canGetCurrentTabTag() throws Exception {
TabHost tabHost = new TabHost(RuntimeEnvironment.application);
TabHost.TabSpec foo = tabHost.newTabSpec("Foo");
TabHost.TabSpec bar = tabHost.newTabSpec("Bar");
TabHost.TabSpec baz = tabHost.newTabSpec("Baz");
tabHost.addTab(foo);
tabHost.addTab(bar);
tabHost.addTab(baz);
tabHost.setCurrentTabByTag("Bar");
assertThat(tabHost.getCurrentTabTag()).isEqualTo("Bar");
}
use of android.widget.TabHost in project robolectric by robolectric.
the class ShadowTabHostTest method setCurrentTabByTagShouldAcceptNullAsParameter.
@Test
public void setCurrentTabByTagShouldAcceptNullAsParameter() throws Exception {
TabHost tabHost = new TabHost(RuntimeEnvironment.application);
TabHost.TabSpec foo = tabHost.newTabSpec("Foo");
tabHost.addTab(foo);
tabHost.setCurrentTabByTag(null);
assertThat(tabHost.getCurrentTabTag()).isEqualTo("Foo");
}
use of android.widget.TabHost in project robolectric by robolectric.
the class ShadowTabSpecTest method shouldGetAndSetTheIndicator.
@Test
public void shouldGetAndSetTheIndicator() throws Exception {
TabHost.TabSpec spec = new TabHost(RuntimeEnvironment.application).newTabSpec("foo");
View view = new View(RuntimeEnvironment.application);
TabHost.TabSpec self = spec.setIndicator(view);
assertThat(self).isSameAs(spec);
assertThat(shadowOf(spec).getIndicatorAsView()).isSameAs(view);
}
use of android.widget.TabHost in project robolectric by robolectric.
the class ShadowTabSpecTest method shouldSetTheContentView.
@Test
public void shouldSetTheContentView() throws Exception {
TabHost.TabSpec foo = new TabHost(RuntimeEnvironment.application).newTabSpec("Foo").setContent(new TabContentFactory() {
public View createTabContent(String tag) {
TextView tv = new TextView(RuntimeEnvironment.application);
tv.setText("The Text of " + tag);
return tv;
}
});
ShadowTabHost.ShadowTabSpec shadowFoo = shadowOf(foo);
TextView textView = (TextView) shadowFoo.getContentView();
assertThat(textView.getText().toString()).isEqualTo("The Text of Foo");
}
use of android.widget.TabHost in project spring-data-document-examples by spring-projects.
the class MainTabWidget method onCreate.
//***************************************
// Activity methods
//***************************************
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources();
TabHost tabHost = getTabHost();
TabHost.TabSpec tabSpec;
Intent intent;
// add events tab
intent = new Intent();
intent.setClass(this, RestListingActivity.class);
tabSpec = tabHost.newTabSpec("restaurants");
tabSpec.setIndicator("Restaurants", res.getDrawable(R.drawable.ic_tab_events));
tabSpec.setContent(intent);
tabHost.addTab(tabSpec);
// add profile tab
intent = new Intent();
intent.setClass(this, FavoritesListingActivity.class);
tabSpec = tabHost.newTabSpec("favorites");
tabSpec.setIndicator("Favorites", res.getDrawable(R.drawable.ic_tab_profile));
tabSpec.setContent(intent);
tabHost.addTab(tabSpec);
// add info tab
intent = new Intent();
intent.setClass(this, InfoActivity.class);
tabSpec = tabHost.newTabSpec("info");
tabSpec.setIndicator("Info", res.getDrawable(R.drawable.ic_tab_info));
tabSpec.setContent(intent);
tabHost.addTab(tabSpec);
}
Aggregations