SherlockFragmentActivity调用中的ClassCastException

时间:2013-04-09 12:54:06

标签: android android-fragments actionbarsherlock

嘿伙计我正在制作一个带有片段的动作栏,每个片段都是一个活动。

为此我使用了Sherlock Action Bar,这是我用来创建标签的代码:

mTabManager.addTab(mTabHost.newTabSpec("Documents").setIndicator("Documents"),
                PolisotFragment.class, null);

这是创建的片段的代码(PolisotFragment.class):

public class PolisotFragment extends SherlockFragmentActivity
{
    ListView LST_Elementaric_Polisot;
    ListView LST_Life_Polisot;
    ListView LST_Finance_Polisot;

     @Override
        protected void onCreate(Bundle savedInstanceState)
     {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.cfragment);

     }
}

当我运行此代码时,我得到了ClassCastException:

  

引起:java.lang.ClassCastException:   com.example.buffy.PolisotFragment

这是我的清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.buffy"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"

      android:label="@string/app_name"
         >
        <activity
            android:name="com.example.buffy.MainActivity"
            android:label="@string/app_name"
             android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.example.buffy.StartApp"
            android:label="@string/app_name"
             android:theme="@style/customTheme" >
        </activity>
          <activity
            android:name="com.example.buffy.SearchUserActivity"
            android:label="@string/app_name"
             android:theme="@style/customTheme" >
        </activity>

          <!--  Client Info  Activity -->
          <activity
            android:name="com.example.buffy.ClientMainActivity"
            android:label="@string/app_name"    
            android:theme="@style/Theme.Sherlock"     
             >
        </activity>
            <!--  Client Info  Activity -->
          <activity
            android:name="com.example.buffy.PolisotFragment"
            android:label="@string/app_name"    
            android:theme="@style/Theme.Sherlock"     
             >
        </activity>
        <activity
            android:name="com.example.buffy.BFragment"
            android:label="@string/app_name"    
            android:theme="@style/Theme.Sherlock"     
             >

        </activity>
                <activity
            android:name="com.example.buffy.DFragment"
            android:label="@string/app_name"    
            android:theme="@style/Theme.Sherlock"     
             >
        </activity>

    </application>
</manifest>

任何人都知道为什么会发生这种情况?

由于

0 个答案:

没有答案