티스토리 뷰
How to showing back button when activity moving
<activity
...
android:name=".SecondActivity"
android:parentActivityName=".MainActivity" >1. 위에 처럼 parent를 등록한다.
1. add as above in manifest.xml
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Respond to the action bar's Up/Home button
case android.R.id.home:
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}
2. 위에 해당 코드 추가.2. add as above in your second activity
kotlin
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.getItemId()) {
android.R.id.home -> {
onBackPressed()
return true
}
}
return super.onOptionsItemSelected(item)
}
출처: https://stackoverflow.com/questions/36457564/display-back-button-of-action-bar-is-not-going-back-in-android
