开始片段尝试使用此代码如何从适配器类
public void startFragment(Context context, int position) {
Activity activity = (Activity) context;
android.app.FragmentManager manager = activity.getFragmentManager();
android.app.FragmentTransaction fragmentTransaction = manager.beginTransaction();
DepartmentDetails departmentDetails = new DepartmentDetails();
Bundle bundle = new Bundle();
bundle.putString("id", departmentList.get(position).id);
bundle.putSerializable("details", departmentList);
departmentDetails.setArguments(bundle);
fragmentTransaction.add(R.id.container, departmentDetails);
fragmentTransaction.commit();
}
开始从适配器类片段,但它fragmentTransaction.add(R.id.container, departmentDetails);
强调红色和在执行它表明
Error:(90, 28) error: no suitable method found for add(int,DepartmentDetails)
method FragmentTransaction.add(Fragment,String) is not applicable
(argument mismatch; int cannot be converted to Fragment)
method FragmentTransaction.add(int,Fragment) is not applicable
(argument mismatch; DepartmentDetails cannot be converted to Fragment)
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
这里是我正在使用的DepartmentDetails片段代码
public class DepartmentDetails extends Fragment implements CallBacks{
ImageView ivProfile;
TextView tvName, tvBasicInfo, tvDescription;
String id, dean;
Departments details;
ArrayList faculty, programs;
RequestParams params;
MyHttp myHttp;
String url;
public DepartmentDetails() {
// Required empty public constructor
}
2017-08-29
Asad
+1
什么是DepartmentDetails片段或SupportFragment? –
+0
其简单片段 –
+1
请更新答案并添加DepartmentDetails片段 –