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