나는 searchview
을 포함하는 액션 바를 가지고 있습니다. 사용자가 검색 버튼을 클릭하고 검색보기를 축소하면 작업 표시 줄의 왼쪽에 뒤로 버튼이 표시됩니다.액션 바에 대한 클릭 버튼을 감지합니다. - (OnOptionsItemSelected는 액션 바 뒤로 버튼을 클릭 할 때 호출하지 않습니다.)
우리가 어떻게이 다시 버튼을 때 사용자가 클릭을 감지 할 수 ?
편집은
내는하지만 너무 호출되지 OnOptionsItemSelected
체크 답변에 따라. 이것은 내 OnOptionsItemSelected
의 코드입니다 :
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (item != null && id == android.R.id.home) {
if (mNavigationDrawerFragment.isDrawerOpen(Gravity.RIGHT)) {
mNavigationDrawerFragment.closeDrawer(Gravity.RIGHT);
} else {
mNavigationDrawerFragment.openDrawer(Gravity.RIGHT);
}
return true;
}
if (id == R.id.action_search) {
return true;
}
return super.onOptionsItemSelected(item);
}
http://stackoverflow.com/questions/14437745/how-to-override-action-bar-back-button-in-android – codePG