如何使用android适配器类,如何从适配器类

开始片段尝试使用此代码如何从适配器类

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片段 –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值