Android Cookie

Android 安卓是最开放的手机操作系统,谷歌安卓APP开发和安卓市场的相关话题

工具栏上的Android后退箭头(AppCompatActivity)

我想在我的应用程序中显示后退箭头button,但是当我将此代码放入代码时,应用程序崩溃: getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); style.xml <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="colorPrimary">@color/PrimaryColor</item> <item name="colorPrimaryDark">@color/PrimaryColorDark</item> <item name="colorAccent">@color/PrimaryColor</item> <item name="colorControlHighlight">@color/ControlHighlight</item> <item name="android:statusBarColor" tools:targetApi="21">@android:color/transparent</item> </style> <style name="ActionBarPopupThemeOverlay" parent="ThemeOverlay.AppCompat.Light" > <item name="android:textColor">#000000</item> </style> <style name="MyCustomTabLayout" parent="Widget.Design.TabLayout"> <item name="tabIndicatorColor">#FFFFFF</item> <item name="tabIndicatorHeight">3dp</item> <item name="tabTextAppearance">@style/MyCustomTabTextAppearance</item> </style> <style name="MyCustomTabTextAppearance" parent="TextAppearance.Design.Tab"> <item name="android:textColor">#FFFFFF</item> </style> toolbar.xml <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_height="@dimen/abc_action_bar_default_height_material" android:elevation="0dp" android:layout_width="match_parent" android:id="@+id/toolbar" android:background="@color/PrimaryColor" app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/ActionBarPopupThemeOverlay"/> 类(而不是片段) : […]