Search in sources :

Example 1 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 2 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 3 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 4 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)

Example 5 with TabHost

use of android.widget.TabHost in project Launcher3 by chislon.

the class FocusHelper method handleTabKeyEvent.

/**
     * Handles key events in the tab widget.
     */
static boolean handleTabKeyEvent(AccessibleTabView v, int keyCode, KeyEvent e) {
    if (!LauncherAppState.getInstance().isScreenLarge())
        return false;
    final FocusOnlyTabWidget parent = (FocusOnlyTabWidget) v.getParent();
    final TabHost tabHost = findTabHostParent(parent);
    final ViewGroup contents = tabHost.getTabContentView();
    final int tabCount = parent.getTabCount();
    final int tabIndex = parent.getChildTabIndex(v);
    final int action = e.getAction();
    final boolean handleKeyEvent = (action != KeyEvent.ACTION_UP);
    boolean wasHandled = false;
    switch(keyCode) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            if (handleKeyEvent) {
                // Select the previous tab
                if (tabIndex > 0) {
                    parent.getChildTabViewAt(tabIndex - 1).requestFocus();
                }
            }
            wasHandled = true;
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if (handleKeyEvent) {
                // Select the next tab, or if the last tab has a focus right id, select that
                if (tabIndex < (tabCount - 1)) {
                    parent.getChildTabViewAt(tabIndex + 1).requestFocus();
                } else {
                    if (v.getNextFocusRightId() != View.NO_ID) {
                        tabHost.findViewById(v.getNextFocusRightId()).requestFocus();
                    }
                }
            }
            wasHandled = true;
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
            // Do nothing
            wasHandled = true;
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            if (handleKeyEvent) {
                // Select the content view
                contents.requestFocus();
            }
            wasHandled = true;
            break;
        default:
            break;
    }
    return wasHandled;
}
Also used : TabHost(android.widget.TabHost) ViewGroup(android.view.ViewGroup)

Aggregations

TabHost (android.widget.TabHost)74 View (android.view.View)29 Intent (android.content.Intent)21 ViewGroup (android.view.ViewGroup)19 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)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 FrameLayout (android.widget.FrameLayout)7 LinearLayout (android.widget.LinearLayout)7 AbsSpinner (android.widget.AbsSpinner)6 QuickContactBadge (android.widget.QuickContactBadge)6