扩展Appcompatactivity后缺少Android ActionBar [英] Android ActionBar missing after extending Appcompatactivity
问题描述
我最近更新了我的应用程序,在我的Activities
中扩展了Appcompatactivity
.从那时起,当我启动一个外部库Intent时,Actionbar
就消失了.
I've recently updated my app extending Appcompatactivity
in my Activities
. Since then, the Actionbar
is gone when I launch an external library Intent.
例如,我正在使用HockeyApp
SDK来启动其FeedbackActivity
For example, I'm using the HockeyApp
SDK to launch their FeedbackActivity
这是我的代码:
FeedbackManager.showFeedbackActivity(this, Uri.fromFile(file));
这是屏幕截图(您可以看到ActionBar
消失了).
And here a screenshot (you can see the ActionBar
is gone).
在我开始扩展Appcompatactivity之前,它一直都可以工作.
It used to work before until I started extending Appcompatactivity.
对于Activities
的其余部分有效. ActionBar is gone
仅当我启动外部库Intent
时.
For the rest of Activities
it works. The ActionBar is gone
only when I launch an external library Intent
.
有什么想法吗?
推荐答案
首先,检查您的主题,如下所示("NoActionBar").这样操作栏就不会出现.如果这是您的问题.请为您的应用添加适当的主题
First, check your theme it may be like below ("NoActionBar"). Then the action bar is not appearing. If this is your issue. please add an appropriate theme for your application
<application
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
/>
如果您的主题没有问题,则可以在XML文件中添加以下内容. (将其添加为XML文件的第一个子项)
if your theme is not a problem, you can add below content to your XML file. (add this as a first child of your XML file)
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
并在创建方法的活动中添加以下内容
and add below content to your activity on create method
protected void onCreate(Bundle savedInstanceState) {
.......
Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(myToolbar);
}
这篇关于扩展Appcompatactivity后缺少Android ActionBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!