MyPanelActivity
には、アイテムのリストを含む recyclerView が含まれています。各アイテムにはクリック イベントがあります。このクリックで開きますDetailsActivity
。
DetailsActivity
全画面ダイアログを開く floatingActionButton があります(私のクラスDetailDialogFragment
extends DialogFragment
)。
DetailDialogFragment
解除付きのアップ/ホームボタンがあります。
問題: ユーザーが [上へ] ボタンをクリックすると、ダイアログはDetailsActivity
閉じられますが、消えてしまい、アプリは に戻りますPanelActivity
。
考えられる理由: ダイアログの [上へ] ボタンの下に、の [上へ] ボタンがありDetailsActivity
ます。ダイアログがアクティビティの上にあり、両方のボタンが同じ場所にある場合、2 つのクリック イベントを発生させることはできますか?
編集:いくつかのコードを表示します。
PanelActivity から DetailsActivity を開きます (recyclerView で 1 つの項目をクリックします)。
Intent intent = new Intent(context, DetailsActivity.class);
intent.putExtra("headerCode", headerCode.getText());
context.startActivity(intent);
DetailsActivity の Up ボタン。
@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 の Up ボタン。
@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);
}