내 활동의 HomeAsUp 버튼에 사소한 문제가 있습니다. 실행 중이 아니거나 더 간결한 ID가 올바른 것이 아닌지 확인하고 있으므로 도구 모음의 HomeAsUp 버튼에 대한 ID는 무엇입니까?
내 코드 :
public boolean onOptionsItemSelected(MenuItem item) {
log.d("item i "+item.getItemId());
log.d("Home id "+android.support.v7.appcompat.R.id.home);
log.d("Home id from R "+R.id.home);
log.d("Home id from R "+R.id.homeAsUp);
if (item.getItemId() == R.id.a_profile_menu_item_edit) {
showProfileEdit();
return true;
} else if (item.getItemId() == android.support.v7.appcompat.R.id.home) {
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
그리고 그 로그에서 인쇄하는 것은 다음과 같습니다.
D/Profile[onOptionsItemSelected] - 121﹕ item id 16908332
D/Profile[onOptionsItemSelected] - 122﹕ Home id 2131492868
D/Profile[onOptionsItemSelected] - 123﹕ Home id from R 2131492868
D/Profile[onOptionsItemSelected] - 124﹕ Home id from R 2131492877
그래서 내 item.id는 16908332이지만 R.id.home, R.id.homeAsUp, android.support.v7.appcompat.R.id.home은 올바른 것이 아닙니다. 어떤 도움을 주시면 감사하겠습니다 ...
ID가 16908332 인 android .R.id.home 이 필요합니다 . 접두사 에있는 android 에 주의하세요 .
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다