Created
August 1, 2011 22:23
-
-
Save paul-english/1119143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If XML element is a tabview, build TabHost, TabWidget, FrameLayout, and LinearLayout to house tabs | |
if (N.equals("tabview")) { | |
TabHost th = new TabHost(context); | |
th.setId(android.R.id.tabhost); | |
TabWidget tw = new TabWidget(context); | |
tw.setId(android.R.id.tabs); | |
FrameLayout fl = new FrameLayout(context); | |
fl.setId(android.R.id.tabcontent); | |
LinearLayout ll = new LinearLayout(context); | |
ll.setOrientation(LinearLayout.VERTICAL); | |
ll.addView(tw); | |
ll.addView(fl); | |
th.addView(ll); | |
Builder.buildChildren(context, rootView, data, th); | |
return th; | |
} | |
// If we're traversing a tab build tab | |
if (N.equals("tab")) { | |
Builder.buildTab(context, rootView, (TabHost) parentView, data); | |
} | |
// ... | |
// ... | |
// ... | |
// Tab building function | |
public static void buildTab(final Context context, final RemoteView rootView, TabHost th, final Element data) { | |
final String label = data.getAttribute("label"); | |
TabSpec spec = th.newTabSpec(label); | |
spec.setIndicator(label); | |
spec.setContent(new TabHost.TabContentFactory() { | |
public View createTabContent(String tag) { | |
//return Builder.getComponent(context, rootView, data, null); | |
TextView tv = new TextView(context); | |
tv.setText(label); | |
return tv; | |
} | |
}); | |
Log.i(TAG, "spec: " + spec.getTag()); | |
th.addTab(spec); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment