El cuadro de diálogo Descartar hace que la actividad finalice
MiPanelActivity
contiene un recyclerView con una lista de artículos. Cada elemento tiene un evento de clic. Este clic se abreDetailsActivity
.
DetailsActivity
tiene un botón de acción flotante que abre un diálogo de pantalla completa (mi claseDetailDialogFragment
se extiendeDialogFragment
)
DetailDialogFragment
tiene un botón Arriba / Inicio con un despido.
El problema: si el usuario hace clic sobre el botón Arriba, se cierra el cuadro de diálogo, pero tambiénDetailsActivity
desaparecerá y la aplicación volverá aPanelActivity
.
Posible motivo: debajo del botón Arriba del cuadro de diálogo se encuentra el botón Arriba delDetailsActivity
. ¿Es posible disparar dos eventos de clic cuando un cuadro de diálogo está sobre una actividad y ambos tienen un botón Arriba en el mismo lugar?
Editar: para mostrar un código.
Abra DetailsActivity desde PanelActivity (haciendo clic en un elemento en recyclerView).
Intent intent = new Intent(context, DetailsActivity.class);
intent.putExtra("headerCode", headerCode.getText());
context.startActivity(intent);
Botón arriba en DetallesActividad.
@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);
}
Abrir el diálogo de pantalla completa en DetallesActividad.
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();
}
Y finalmente, el botón Arriba en 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);
}