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)));
}
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);
}
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);
}
}
}
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);
}
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;
}
Aggregations