Skip to content

Commit e7335da

Browse files
authored
魔法-修复
1 parent e571391 commit e7335da

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ChaosCrystal/ActionBar/为ActionBar添加返回按钮.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,19 @@ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
1919
// If your minSdkVersion is 11 or higher, instead use:
2020
// getActionBar().setDisplayHomeAsUpEnabled(true);
2121
```
22+
监听返回按钮事件
23+
24+
> 它的 id 是 home,可以使用重载 `onOptionsItemSelected` 的方式进行监听。
25+
``` java
26+
@Override
27+
public boolean onOptionsItemSelected(MenuItem item)
28+
{
29+
// TODO Auto-generated method stub
30+
if(item.getItemId() == android.R.id.home)
31+
{
32+
finish();
33+
return true;
34+
}
35+
return super.onOptionsItemSelected(item);
36+
}
37+
```

0 commit comments

Comments
 (0)