我的值
companyName
在Myfragment
课程中我需要将此companyName
值传递给MyAdapter
课程。并且没有从Myfragment
移动到MyAdapter
活动。有人可以告诉我该怎么办?我对其他网站上的每场比赛感到困惑。
这是我的适配器类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Log.d("test",""+deliveryListBeans.size());
LayoutInflater inflater=(LayoutInflater)ct.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v=inflater.inflate(R.layout.list_view_for_delivery_list,null);
Button delivered=(Button)v.findViewById(R.id.do_delivered);
delivered.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent deliveryUpdate=new Intent(ct, MyOwn.class);
deliveryUpdate.putExtra("invoiceId",dlb.getInvoiceNo());
ct.startActivity(deliveryUpdate);
}
});
return v;
}
在
setOnClickListener
我需要来自companyName
类的fragment
值,以便我可以在网址中使用它。
这是我的片段类
public class DeliveryList extends Fragment {
private List<DeliveryListBean> dlblistbean= new ArrayList<DeliveryListBean>();
ListView listview;
Button delivered;
String companyName;}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
final View rootView = inflater.inflate(R.layout.fragment_delivery_list,container,false);
listview=(ListView) rootView.findViewById(R.id.deliveryListView);
companyName=this.getArguments().getString("companyName");
listview.setAdapter(deliveryListAdapter);
return rootView;
}
答案 0 :(得分:0)
在您的适配器类
中public class MyAdapter {
private Context mContext;
private String mCompanyName;
public MyAdapter(Context context, String companyName) {
mContext = context;
mCompanyName = companyName;
}
}