title: Error inflating class switch, ActionBarSherlock (InflateException)
body: <p>I'm running into a pain of an error. I have a SherlockFragmentActivity, and at least two SherlockFragments. Both use onCreateView to inflate an xml file. LoginFragment, however, has a switch widget: econ fragment does not. If I add a switch widget into econfragment.xml, that causes a crash of the same type (while loginfragment is commented out of implementation). If I remove the switch widget from loginfragment, a similar error shows up for RadioGroup - but econfragment already has a radio group and produces no errors. Here is the relevant code:</p>
  
  <p>Polling:</p>
  
  <pre><code>import java.util.ArrayList;
  import library.DatabaseHandler;
  import org.json.JSONObject;
  import com.actionbarsherlock.R;
  import com.actionbarsherlock.app.ActionBar;
  import com.actionbarsherlock.app.ActionBar.Tab;
  import com.actionbarsherlock.app.SherlockFragment;
  import com.actionbarsherlock.app.SherlockFragmentActivity;
  import android.app.AlertDialog;
  import android.app.Dialog;
  import android.app.ProgressDialog;
  import android.content.Context;
  import android.content.DialogInterface;
  import android.content.Intent;
  import android.content.SharedPreferences;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View.OnClickListener;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Switch;
  import android.widget.TextView;
  import android.widget.Toast;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentActivity;
  import android.support.v4.app.FragmentManager;
  import android.support.v4.app.FragmentPagerAdapter;
  import android.support.v4.app.FragmentTransaction;
  import android.support.v4.view.ViewPager;
  import android.support.v4.view.ViewPager.OnPageChangeListener;
  
  public class Polling extends SherlockFragmentActivity {
      private ViewPager mViewPager;
      private TabsAdapter mTabsAdapter;
      private final static String TAG = "21st Polling:";
      private Button loginButton;
      private Button registerButton;
      private Switch rememberSwitch;
      SharedPreferences sharedPreferences;
      Toast toast;
  
      public void loginReport(int responseCode) {
          //if login succeeded
          if (responseCode == 1) {
              loginButton = (Button)findViewById(R.id.loginButton);
              loginButton.setText("Log Out");
              Context context = getApplicationContext();
              int duration = Toast.LENGTH_LONG;
              Toast toast = Toast.makeText(context, "Logged in.", duration);
              toast.show();
  
          }
          if (responseCode == 0) {
              Context context = getApplicationContext();
              int duration = Toast.LENGTH_LONG;
              Toast toast = Toast.makeText(context, "Incorrect username/password", duration);
              toast.show();
          }
          if (responseCode == 2) {
              //remove user from active sql db here rather than LoginFragment?!
              Context context = getApplicationContext();
              int duration = Toast.LENGTH_SHORT;
              Toast toast = Toast.makeText(context, "Logged out", duration);
              toast.show();
          }
      }
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          Log.v(TAG, "onCreate");
          mViewPager = new ViewPager(this);
          mViewPager.setId(R.id.pager);
          setContentView(mViewPager);
          ActionBar bar = getSupportActionBar();
          bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
          bar.setDisplayShowTitleEnabled(false);
          bar.setDisplayShowHomeEnabled(false);
  
          mTabsAdapter = new TabsAdapter(this, mViewPager);
          //mTabsAdapter.addTab(bar.newTab().setText(R.string.login),
                  //LoginFragment.class, null);
          mTabsAdapter.addTab(bar.newTab().setText(R.string.economics),
                  EconFragment.class, null);
          mTabsAdapter.addTab(bar.newTab().setText(R.string.elections),
                  ElectionsFragment.class, null);
          mTabsAdapter.addTab(bar.newTab().setText(R.string.politics),
                  PoliticsFragment.class, null);
          mTabsAdapter.addTab(bar.newTab().setText(R.string.science),
                  ScienceFragment.class, null);
          mTabsAdapter.addTab(bar.newTab().setText(R.string.finance),
                  FinanceFragment.class, null);
          mTabsAdapter.addTab(bar.newTab().setText(R.string.religion),
                  ReligionFragment.class, null);
          mTabsAdapter.addTab(bar.newTab().setText(R.string.military),
                  MilitaryFragment.class, null);
          mTabsAdapter.addTab(bar.newTab().setText(R.string.international),
                  InternationalFragment.class, null); 
          //Log.v(TAG, (String)bar.getTabAt(0).getText());
  
      }
  
      public void login(int id)
      {
          JSONObject json_userJsonObject;
          //DatabaseHandler db = new DatabaseHandler(getApplicationContext());
          //JSONObject json_user = json.getJSONObject("user");
          /*sharedPreferences.edit().putBoolean("user_logged_in", true).commit();*/
          //startActivityForResult(new Intent(Polling.this, LOGIN_DESTINATION), LOGIN_REQUEST_CODE);
      }
  
      protected void onSaveInstanceState(Bundle outState) {
          super.onSaveInstanceState(outState);
          //outState.putInt("tab", getSupportActionBar().getSelectedNavigationIndex());
      }
  
      public void onResume() {
          super.onResume();
          Log.v(TAG, "onResume");
  
      }
  
      protected void onPause() {
          super.onPause();    
          Log.d("Econ", "onpause");
      }
  
      public static class TabsAdapter extends FragmentPagerAdapter
      implements ActionBar.TabListener, ViewPager.OnPageChangeListener {
          private final Context mContext;
          private final ActionBar mActionBar;
          private final ViewPager mViewPager;
          private final ArrayList&lt;TabInfo&gt; mTabs = new ArrayList&lt;TabInfo&gt;();
  
          static final class TabInfo {
              private final Class&lt;?&gt; clss;
              private final Bundle args;
  
              TabInfo(Class&lt;?&gt; _class, Bundle _args) {
                  clss = _class;
                  args = _args;
              }
          }
  
          public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) {
              super(activity.getSupportFragmentManager());
              mContext = activity;
              mActionBar = activity.getSupportActionBar();
              mViewPager = pager;
              mViewPager.setAdapter(this);
              mViewPager.setOnPageChangeListener(this);
          }
  
          public void addTab(ActionBar.Tab tab, Class&lt;?&gt; clss, Bundle args) {
              TabInfo info = new TabInfo(clss, args);
              tab.setTag(info);
              tab.setTabListener(this);
              mTabs.add(info);
              mActionBar.addTab(tab);
              notifyDataSetChanged();
          }
  
  
          public int getCount() {
              return mTabs.size();
          }
  
          public SherlockFragment getItem(int position) {
              TabInfo info = mTabs.get(position);
              return (SherlockFragment)Fragment.instantiate(mContext, info.clss.getName(), info.args);
          }
  
  
          public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
          }
  
  
          public void onPageSelected(int position) {
              mActionBar.setSelectedNavigationItem(position);
          }
  
  
          public void onPageScrollStateChanged(int state) {
          }
  
  
          public void onTabSelected(Tab tab, FragmentTransaction ft) {
              mViewPager.setCurrentItem(tab.getPosition());
              //Log.v(TAG, "clicked");
              Object tag = tab.getTag();
              for (int i=0; i&lt;mTabs.size(); i++) {
                  if (mTabs.get(i) == tag) {
                      mViewPager.setCurrentItem(i);
                  }
              }
          }
  
          public void onTabUnselected(Tab tab, FragmentTransaction ft) {}
  
          public void onTabReselected(Tab tab, FragmentTransaction ft) {}
  
          public void onTabReselected(Tab tab, android.app.FragmentTransaction ft) {}
  
          public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) {}
      }
  </code></pre>
  
  <p>LoginFragment:</p>
  
  <pre><code>import com.actionbarsherlock.R;
  import com.actionbarsherlock.app.SherlockFragment;
  import android.app.Activity;
  import android.app.ProgressDialog;
  import android.content.Context;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.TableLayout;
  import android.widget.TableRow;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class LoginFragment extends SherlockFragment {
  
      Button loginButton;
      TextView loginErrorMsg;
      Polling activity;
  
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          Log.v("x", "oncreateview");
          View v = inflater.inflate(R.layout.loginfragment, container, false);
          return v;
      }
  </code></pre>
  
  <p>EconFragment:</p>
  
  <pre><code>import com.actionbarsherlock.R;
  import com.actionbarsherlock.app.SherlockFragment;
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.content.Context;
  import android.content.Intent;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.View.OnClickListener;
  import android.view.ViewGroup.LayoutParams;
  import android.view.inputmethod.InputMethodManager;
  import android.widget.Button;
  import android.widget.LinearLayout;
  import android.widget.RelativeLayout;
  import android.widget.ScrollView;
  import android.widget.TableLayout;
  import android.widget.TableRow;
  import android.widget.TextView;
  
  public class EconFragment extends SherlockFragment {
  
      private TableLayout questionContainer;
      int pos = 0;
      private String[] titles = {"The first title ", "hallo1","hallo2", "hallo3",
              "hallo4", "hallo5","hallo6", "hallo7","hallo8", "hallo9"};
  
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          Log.v("Econ", "onCreateView");
          View v = inflater.inflate(R.layout.econfragment, container, false);
          questionContainer = (TableLayout) v.findViewById(R.id.questionContainer);
          //bs
          int leftMargin=5;
          int topMargin=5;
          int rightMargin=5;
          int bottomMargin=5;
          while (pos &lt; 10) {
          View question = inflater.inflate(R.layout.question, null);
          question.setId(pos);
          TextView title = (TextView) question.findViewById(R.id.questionTextView);
          title.setText(titles[pos]);
          Button charts = (Button) question.findViewById(R.id.chartsButton);
          charts.setId(pos);
          charts.setOnClickListener(chartsListener);
          TableRow tr = (TableRow) question;
          TableLayout.LayoutParams trParams = new TableLayout.LayoutParams(
                  TableLayout.LayoutParams.MATCH_PARENT,
                  TableLayout.LayoutParams.WRAP_CONTENT);
          trParams.setMargins(leftMargin, topMargin, rightMargin, bottomMargin);
          tr.setLayoutParams(trParams);
          Log.v("econ", "while loop");
          questionContainer.addView(tr);
          pos++;
          }
  
          return v;
      }
  </code></pre>
  
  <p>And the two XML files; loginfragment.xml and econfragment.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:id="@+id/loginScrollView"&gt;
  &lt;TableLayout 
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"
      android:padding="5dp" &gt;
  
      &lt;ImageView
          android:id="@+id/logoImageView"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/logo" 
          android:contentDescription="@string/app_name"
          /&gt;
  
      &lt;TextView
          android:id="@+id/demoTextView"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/logDetails" android:gravity="center_horizontal|center"&gt;
  
          &lt;/TextView&gt;
  
      &lt;EditText
          android:id="@+id/emailEditText"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:hint="@string/loginHint"
          android:imeOptions="actionNext"
          android:inputType="textEmailAddress" android:padding="10dp"/&gt;
  
      &lt;EditText
          android:id="@+id/passEditText"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:hint="@string/password"
          android:imeOptions="actionDone"
          android:inputType="textPassword" android:padding="10dp"/&gt;
  
      &lt;Switch
          android:id="@+id/rememberSwitch"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/rememberDetails" android:padding="10dp" android:gravity="right"/&gt;
  
      &lt;TableRow
          android:id="@+id/tableRow1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_weight="1" &gt;
  
          &lt;Button
              android:id="@+id/registerButton"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="bottom"
              android:layout_weight="2"
              android:padding="5dp"
              android:text="@string/register" /&gt;
  
          &lt;Button
              android:id="@+id/loginButton"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="bottom"
              android:layout_weight="2"
              android:padding="5dp"
              android:text="@string/login" /&gt;
      &lt;/TableRow&gt; 
  
  &lt;/TableLayout&gt;
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p>econfragment.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
     &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/scrollView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" &gt;
  
          &lt;TableLayout 
              android:id="@+id/questionContainer"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"&gt;
  
          &lt;/TableLayout&gt;
       &lt;/ScrollView&gt;
  </code></pre>
  
  <p>Is there something that I should be doing fundamentally differently? I should note that this error <em>only</em> occurs on Gingerbread or lower - it works perfectly fine on ICS, for example. The whole point of me using ABS is to get the backwards compatibility, so I'm a bit nonplussed with this error at the moment!</p>