How To Start Fragment From Adapter Class
trying to start fragment from adapter class using this code public void startFragment(Context context, int position) { Activity activity = (Activity) context; android.app.F
Solution 1:
You can open fragment from adapter class using below code;
Fragmentfragment=newMyFragment();
FragmentManagerfm= context.getSupportFragmentManager();
FragmentTransactionft= fm.beginTransaction();
ft.replace(R.id.content_frame, fragment);
ft.commit();
Solution 2:
Add in your DepartmentDetails fragment class
import android.support.v4.app.Fragment ;
instead of
import android.app.Fragment
Solution 3:
Please try with following code.
Fragmentfragment=newMyFragment();
FragmentTransactionfragmentTransaction= getSupportFragmentManager().beginTransaction();
FragmentTransactionft= fm.beginTransaction();
ft.replace(R.id.content_frame, fragment);
ft.commit();
Post a Comment for "How To Start Fragment From Adapter Class"