Search in sources :

Example 11 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 12 with TabHost

use of android.widget.TabHost in project Trello-Android by chrisHoekstra.

the class TrelloTabActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tab);
    TabHost tabHost = getTabHost();
    tabHost.addTab(tabHost.newTabSpec(BOARD_TAB).setIndicator("Boards", null).setContent(new Intent().setClass(this, BoardActivityGroup.class)));
    tabHost.addTab(tabHost.newTabSpec(NOTIFICATION_TAB).setIndicator("Notifications", null).setContent(new Intent().setClass(this, NotificationsActivity.class)));
    tabHost.addTab(tabHost.newTabSpec(PROFILE_TAB).setIndicator("Profile", null).setContent(new Intent().setClass(this, ProfileActivity.class)));
}
Also used : TabHost(android.widget.TabHost) Intent(android.content.Intent)

Example 13 with TabHost

use of android.widget.TabHost in project cw-omnibus by commonsguy.

the class TabDemo method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    TabHost tabs = (TabHost) findViewById(R.id.tabhost);
    tabs.setup();
    TabHost.TabSpec spec = tabs.newTabSpec("tag1");
    spec.setContent(R.id.tab1);
    spec.setIndicator("Clock");
    tabs.addTab(spec);
    spec = tabs.newTabSpec("tag2");
    spec.setContent(R.id.tab2);
    spec.setIndicator("Button");
    tabs.addTab(spec);
}
Also used : TabHost(android.widget.TabHost)

Example 14 with TabHost

use of android.widget.TabHost in project android_frameworks_base by ParanoidAndroid.

the class RenderSessionImpl method postInflateProcess.

/**
     * Post process on a view hierachy that was just inflated.
     * <p/>At the moment this only support TabHost: If {@link TabHost} is detected, look for the
     * {@link TabWidget}, and the corresponding {@link FrameLayout} and make new tabs automatically
     * based on the content of the {@link FrameLayout}.
     * @param view the root view to process.
     * @param projectCallback callback to the project.
     */
private void postInflateProcess(View view, IProjectCallback projectCallback) throws PostInflateException {
    if (view instanceof TabHost) {
        setupTabHost((TabHost) view, projectCallback);
    } else if (view instanceof QuickContactBadge) {
        QuickContactBadge badge = (QuickContactBadge) view;
        badge.setImageToDefault();
    } else if (view instanceof AdapterView<?>) {
        // get the view ID.
        int id = view.getId();
        BridgeContext context = getContext();
        // get a ResourceReference from the integer ID.
        ResourceReference listRef = context.resolveId(id);
        if (listRef != null) {
            SessionParams params = getParams();
            AdapterBinding binding = params.getAdapterBindings().get(listRef);
            // if there was no adapter binding, trying to get it from the call back.
            if (binding == null) {
                binding = params.getProjectCallback().getAdapterBinding(listRef, context.getViewKey(view), view);
            }
            if (binding != null) {
                if (view instanceof AbsListView) {
                    if ((binding.getFooterCount() > 0 || binding.getHeaderCount() > 0) && view instanceof ListView) {
                        ListView list = (ListView) view;
                        boolean skipCallbackParser = false;
                        int count = binding.getHeaderCount();
                        for (int i = 0; i < count; i++) {
                            Pair<View, Boolean> pair = context.inflateView(binding.getHeaderAt(i), list, false, /*attachToRoot*/
                            skipCallbackParser);
                            if (pair.getFirst() != null) {
                                list.addHeaderView(pair.getFirst());
                            }
                            skipCallbackParser |= pair.getSecond();
                        }
                        count = binding.getFooterCount();
                        for (int i = 0; i < count; i++) {
                            Pair<View, Boolean> pair = context.inflateView(binding.getFooterAt(i), list, false, /*attachToRoot*/
                            skipCallbackParser);
                            if (pair.getFirst() != null) {
                                list.addFooterView(pair.getFirst());
                            }
                            skipCallbackParser |= pair.getSecond();
                        }
                    }
                    if (view instanceof ExpandableListView) {
                        ((ExpandableListView) view).setAdapter(new FakeExpandableAdapter(listRef, binding, params.getProjectCallback()));
                    } else {
                        ((AbsListView) view).setAdapter(new FakeAdapter(listRef, binding, params.getProjectCallback()));
                    }
                } else if (view instanceof AbsSpinner) {
                    ((AbsSpinner) view).setAdapter(new FakeAdapter(listRef, binding, params.getProjectCallback()));
                }
            }
        }
    } else if (view instanceof ViewGroup) {
        ViewGroup group = (ViewGroup) view;
        final int count = group.getChildCount();
        for (int c = 0; c < count; c++) {
            View child = group.getChildAt(c);
            postInflateProcess(child, projectCallback);
        }
    }
}
Also used : SessionParams(com.android.ide.common.rendering.api.SessionParams) TabHost(android.widget.TabHost) ViewGroup(android.view.ViewGroup) BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) AbsListView(android.widget.AbsListView) FakeAdapter(com.android.layoutlib.bridge.impl.binding.FakeAdapter) FakeExpandableAdapter(com.android.layoutlib.bridge.impl.binding.FakeExpandableAdapter) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) ExpandableListView(android.widget.ExpandableListView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) ExpandableListView(android.widget.ExpandableListView) QuickContactBadge(android.widget.QuickContactBadge) AdapterBinding(com.android.ide.common.rendering.api.AdapterBinding) AbsSpinner(android.widget.AbsSpinner) AdapterView(android.widget.AdapterView) ResourceReference(com.android.ide.common.rendering.api.ResourceReference) ExpandableListView(android.widget.ExpandableListView)

Example 15 with TabHost

use of android.widget.TabHost in project android_frameworks_base by ParanoidAndroid.

the class MediaDump method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // TODO: Read/Write the settings.
    setContentView(R.layout.main);
    TabHost tab = getTabHost();
    // Setup video dumping tab
    TabHost.TabSpec videoDumpTab = tab.newTabSpec("VideoDump");
    videoDumpTab.setIndicator("VideoDump");
    Intent videoDumpIntent = new Intent(this, VideoDumpActivity.class);
    videoDumpTab.setContent(videoDumpIntent);
    tab.addTab(videoDumpTab);
    // Setup rgb player tab
    TabHost.TabSpec rgbPlayerTab = tab.newTabSpec("RgbPlayer");
    rgbPlayerTab.setIndicator("RgbPlayer");
    Intent rgbPlayerIntent = new Intent(this, RgbPlayerActivity.class);
    rgbPlayerTab.setContent(rgbPlayerIntent);
    tab.addTab(rgbPlayerTab);
}
Also used : TabHost(android.widget.TabHost) Intent(android.content.Intent)

Aggregations

TabHost (android.widget.TabHost)73 View (android.view.View)30 Intent (android.content.Intent)21 ViewGroup (android.view.ViewGroup)18 ListView (android.widget.ListView)18 Test (org.junit.Test)17 TabWidget (android.widget.TabWidget)15 AdapterView (android.widget.AdapterView)13 AbsListView (android.widget.AbsListView)12 ExpandableListView (android.widget.ExpandableListView)12 TextView (android.widget.TextView)11 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 FrameLayout (android.widget.FrameLayout)7 LinearLayout (android.widget.LinearLayout)7 AbsSpinner (android.widget.AbsSpinner)6 QuickContactBadge (android.widget.QuickContactBadge)6