You need to use a Theme.AppCompat theme (or descendant) with this activity

一個小問題,順手記錄一下。

今天做項目的時候,有個小小的需求,就是讓一個activity運行但不顯示界面出來,網上找了一下,方法很簡單,只需要在你的清單文件中,將該activity的主題改成如下即可:

android:theme="@android:style/Theme.NoDisplay"

但是當我運行的時候,報了一個錯誤:

You need to use a Theme.AppCompat theme (or descendant) with this activity


後來在stackoverflow上找到了答案:



意思是,你的這個activity是不是繼承了v7包裏的包裝過的activity,比如他這裏說的ActionBarActivity,如果是的話就改一下,我看了我的是繼承了AppCompatActivity,然後改成Activity就可以了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章