jcpalmer wrote:
> I have a remove assistant app, which allows customers to perform a
> subset of functions of a desktop application, untethered.  Results are
> communicated back & forth via messages left at a license server.  In
> order to have a single source for the logic of the assistant, yet run
> on multiple platforms (Swing, MIDP, & Android), I write a driver
> composed of Database, Network, & Display pieces.
> 
> The Android driver is nearly complete, but I run into a brick wall
> when it comes to Tabs.  All views are instanced calling code, not XML
> defined.  I already have the view before I try to add it.  I tried sub-
> classing TabHost:
> ==============================================================
>     class DynamicTabHost extends android.widget.TabHost{
>         public DynamicTabHost(android.content.Context context){
>             super(context);
>             super.setup(); // errors with: Your TabHost must have a
> TabWidget whose id attribute is 'android.R.id.tabs'
>         }
>         public void addTab(View view, String tabTitle){
>             android.widget.TabHost.TabSpec tabSpec = super.newTabSpec
> (tabTitle);
>             tabSpec.setContent(new PreExistingViewFactory(view));
>             tabSpec.setIndicator(tabTitle);
> 
>             super.addTab(tabSpec);
>         }
>     }
> 
>     class PreExistingViewFactory implements
> android.widget.TabHost.TabContentFactory{
>         private final View preExisting;
> 
>         public PreExistingViewFactory(View view){ preExisting =
> view; }
>         public View createTabContent(String tag) { return
> preExisting; }
>     }
> ============================================================
> As is shown in the code, it errors in setup.  Looking further down in
> setup() I will also get this exception too:
> Your TabHost must have a FrameLayout whose id attribute is
> 'android.R.id.tabcontent
> 
> Is there a way to trick setup() into instancing me mTabWidget &
> mTabContent members?

I would start by following the instructions from the error message.

You do not appear to be adding a TabWidget whose id is android.R.id.tabs
before calling super.setup(), nor are you adding a FrameLayout whose id
is android.R.id.tabcontent before calling super.setup().

Create such objects, add them via addView() to yourself (with
appropriate LayoutParams), then call super.setup() and see if it works.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Development Wiki: http://wiki.andmob.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to