내 PanelActivity
에는 항목 목록이있는 recyclerView가 있습니다. 각 항목에는 클릭 이벤트가 있습니다. 이 클릭은 DetailsActivity
을 엽니 다.대화 상자가 닫히면 작업 완료
DetailsActivity
에는 전체 화면 대화 상자 (내 클래스 DetailDialogFragment
은 DialogFragment
)를 여는 floatingActionButton이 있습니다.
DetailDialogFragment
에는 해제 버튼이 있습니다.
문제 : 사용자가 위로 버튼을 클릭하면 대화 상자가 닫히고 DetailsActivity
도 사라지고 앱이 PanelActivity
으로 돌아갑니다.
가능한 이유 : 대화 상자의 위로 단추 아래에 DetailsActivity
의 위로 단추가 있습니다. 대화 상자가 액티비티 위에 있고 둘 다 같은 위치에 위로 버튼이있을 때 두 번의 클릭 이벤트를 실행할 수 있습니까?
편집 : 일부 코드를 표시합니다.
열기 세부 정보 PanelActivity의 활동 (recyclerView에서 항목 하나를 클릭).
Intent intent = new Intent(context, DetailsActivity.class);
intent.putExtra("headerCode", headerCode.getText());
context.startActivity(intent);
DetailsActivity의 위쪽 버튼.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Respond to the action bar's Up/Home button
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
DetailsActivity에서 전체 화면 대화 상자를 엽니 다.
private void showCreateDetailDialog() {
FragmentManager fragmentManager = getSupportFragmentManager();
DetailDialogFragment newFragment = new DetailDialogFragment();
// The device is smaller, so show the fragment fullscreen
FragmentTransaction transaction = fragmentManager.beginTransaction();
// For a little polish, specify a transition animation
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
// To make it fullscreen, use the 'content' root view as the container
// for the fragment, which is always the root view for the activity
transaction.add(android.R.id.content, newFragment)
.addToBackStack(null).commit();
}
마지막으로 DetailDialogFragment의 위로 버튼.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.save) {
validateForm();
return true;
} else if (id == android.R.id.home) {
// handle close button click here
dismiss();
return true;
}
return super.onOptionsItemSelected(item);
}
일부 소스 코드 – Krish
@Krish 내 게시물을 편집했습니다. – JCarlos