Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
法一:
當在AndroidManifest.xml文件的application的節點設置了屬性:
android:theme="@android:style/Theme.NoTitleBar
而Activity繼承了ActionBarActivity就回出現上述錯誤,解決的辦法就是讓Activity去繼承Activity而不是ActionBarActivity
改完之後刪掉報錯的部分,然後別忘了導入Activity包
法二:
在AndroidMenifest.xml中加入一句:
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
例子:
<activity
android:name="com.vmoksha.BaseActivity"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
然後在styles.xml中加入主題資源:
<style name="Theme.AppCompat.Light.NoActionBar" parent="@style/Theme.AppCompat.Light">
<item name="android:windowNoTitle">true</item>
</style>
即可