Skip to content Skip to sidebar Skip to footer

.activitynotfoundexception: Unable To Find Explicit Activity Class

I want to start fragment activity in a textview click in activity class but I get below exception.I am new to android please help.This is my code Intent intent=new Intent(this,T

Solution 1:

if ThreeFragment extends Fragment then you should initialize it like this

FragmentManagerfragmentManager= getFragmentManager();
FragmentTransactionfragmentTransaction= fragmentManager.beginTransaction();
Fragmentfragment=newThreeFragment();
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.commit();

UPDATE:

R.id.fragment_container is a FrameLayout that will contain your fragment.

Include this at the bottom of Activity layout in which you want to initialize the fragment

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

and if ThreeFragment extends AppCompatActivity or Activity the in your manifest you need to include it like this

<activityandroid:name=".ThreeFragment"android:label="@string/app_name"></activity>

Post a Comment for ".activitynotfoundexception: Unable To Find Explicit Activity Class"