2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

setDisplayHomeAsUpEnabledが使えなかった時の戻るボタン実装方法

Last updated at Posted at 2016-08-22

なんか

actionBar.setDisplayHomeAsUpEnabled(true);

が使えないよーって人でもManifestに1行加えると左上の戻るボタンが実装できる

例えばhogehogeActivityに戻るボタンを実装したいときは

AndroidManifest.xml
<activity android:name=".hogeActivity" />

のところを

AndroidManifest.xml
<activity android:name=".hogeActivity"
            android:parentActivityName=".hogeActivity"/>

に変えるだけ実装できる。

parent先のActivityは適当でも動いた

screenshot_2016-08-23-04-25-43_1024.jpg

さっとググった感じなんでこれだけで実装できるかというと
Activity.classでparentがNullでないときsetDisplayHomeAsUpEnabled(true)を実行するように元々定義されているっぽいです

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?