Search in sources :

Example 16 with TabHost

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");
}
Also used : TabHost(android.widget.TabHost) Test(org.junit.Test)

Example 17 with TabHost

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");
}
Also used : TabHost(android.widget.TabHost) Test(org.junit.Test)

Example 18 with TabHost

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);
}
Also used : TabHost(android.widget.TabHost) TextView(android.widget.TextView) View(android.view.View) Test(org.junit.Test)

Example 19 with TabHost

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");
}
Also used : TabHost(android.widget.TabHost) TabContentFactory(android.widget.TabHost.TabContentFactory) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) Test(org.junit.Test)

Example 20 with TabHost

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);
}
Also used : TabHost(android.widget.TabHost) Intent(android.content.Intent) Resources(android.content.res.Resources)

Aggregations

TabHost (android.widget.TabHost)70 View (android.view.View)29 Intent (android.content.Intent)21 ViewGroup (android.view.ViewGroup)18 Test (org.junit.Test)17 ListView (android.widget.ListView)15 TabWidget (android.widget.TabWidget)14 AdapterView (android.widget.AdapterView)13 AbsListView (android.widget.AbsListView)12 ExpandableListView (android.widget.ExpandableListView)12 ActionMenuView (android.widget.ActionMenuView)10 ActionMenuItemView (com.android.internal.view.menu.ActionMenuItemView)10 IconMenuItemView (com.android.internal.view.menu.IconMenuItemView)10 ListMenuItemView (com.android.internal.view.menu.ListMenuItemView)10 MenuView (com.android.internal.view.menu.MenuView)10 TextView (android.widget.TextView)9 FrameLayout (android.widget.FrameLayout)7 LinearLayout (android.widget.LinearLayout)7 AbsSpinner (android.widget.AbsSpinner)6 QuickContactBadge (android.widget.QuickContactBadge)6