Skip to content

Commit 7a382db

Browse files
authored
魔法-创生
1 parent 2d55746 commit 7a382db

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# 为 ActionBar 添加返回按钮
2+
3+
在 AndroidManifest.xml 文件中配置
4+
5+
``` xml
6+
<activity android:name="com.gcssloop.test.viewsupport.TestCustomViewActivity"
7+
android:parentActivityName="com.gcssloop.test.MainActivity">
8+
<!-- 支持 4.0 以下的设备 -->
9+
<meta-data
10+
android:name="android.support.PARENT_ACTIVITY"
11+
android:value="com.gcssloop.test.MainActivity" />
12+
</activity>
13+
```
14+
在 onCrate 中设置
15+
16+
```
17+
// 3.0+
18+
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
19+
// If your minSdkVersion is 11 or higher, instead use:
20+
// getActionBar().setDisplayHomeAsUpEnabled(true);
21+
```

0 commit comments

Comments
 (0)