简体   繁体   English

(AppCompat) 没有 UI 的活动

[英](AppCompat) Activity without UI

As per this post , I know I am allowed to create an activity that has no user interface by declaring your activity like below:根据这篇文章,我知道我可以通过如下声明您的活动来创建一个没有用户界面的活动:

<activity
    android:name=".NoUIActivity"
    android:theme="@android:style/Theme.NoDisplay">
</activity>

My problem is NoUIActivity extends AppCompatActivity.我的问题是 NoUIActivity 扩展了 AppCompatActivity。 If I use the android:theme line above, it gives me error saying I should use the corresponding AppCompat theme.如果我使用上面的android:theme行,它会给我错误提示我应该使用相应的 AppCompat 主题。 Help please.请帮忙。 Thanks!谢谢!

  1. Create an app with single activity创建具有单个活动的应用
  2. Delete the layout xml which you don't need删除不需要的布局xml
  3. Remove setContentView line (generated by Android Studio),in Activity's onCreate() method移除 Activity 的onCreate()方法中的setContentView行(由 Android Studio 生成onCreate()
  4. Call finish() when done finish()调用finish()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM