0

Here is my code from activity

Button dialogButton1 = (Button) dialog.findViewById(R.id.btn1);
    dialogButton1.setOnClickListener(new View.OnClickListener() {
        @SuppressLint("ResourceType")
        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setClass(MainActivity.this, SendFragment.class);
            startActivity(intent);
            dialog.dismiss();

        }
    });

It gives error : have you declared this activity in your AndroidManifest.xml?

1 Answers1

0

You cannot call Fragments Using Intents, Fragments are a part of Activity and you can add, remove or replace Fragment . Create a FrameLayout in activity layout xml file.

Then do this in your activity to add fragment:

FragmentManager manager = getFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.add(R.id.container,YOUR_FRAGMENT_NAME,YOUR_FRAGMENT_STRING_TAG);
transaction.addToBackStack(null);
transaction.commit();
Wahdat Jan
  • 3,988
  • 3
  • 21
  • 46