How to replace fragment with cointainerviewId in a Dialogbox

Refresh

December 2018

Views

35 time

3

I have to replace id with the fragment, here is my source:

 public void showEmojiDialog() {
    final Dialog dialog = new Dialog(MainActivity.this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCancelable(false);
    dialog.setContentView(R.layout.activity_check);
    mEditEmojicon1 = (EmojiconEditText) dialog.findViewById(R.id.editEmojicon1);
    getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.editEmojicon1, EmojiconsFragment.newInstance(false))
            .commit();
    Button dialogButton = (Button) dialog.findViewById(R.id.send_btn);
    dialogButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    dialog.show();

}

Facing issue here:

getSupportFragmentManager()
        .beginTransaction()
        .replace(R.id.editEmojicon1, EmojiconsFragment.newInstance(false))
        .commit();

Caused by: java.lang.IllegalArgumentException: No view found for id 0x7f0d007c (com.sample.testapplication:id/editEmojicon1) for fragment EmojiconsFragment{1f7f3e0d #0 id=0x7f0d007c}

I am confused to replace id R.id.editEmojicon1 with EmojiconsFragment but as I am in dialogbox it is not getting its view.

Here is what I want to show in a dialogbox.

1 answers

0

Вместо getSupportFragmentManager()использования getChildFragmentManager().