我在一个recycler中设置了fragment视图,其中包含20条记录。当我点击cardview中的任何一条时,下一个片段中会显示swipeard。我将一些数据从cardview传递给swipecard。我需要在移动到SwipeCard Fragment后设置所有20个SwipeCards。但是只显示一个SwipeCard。
这是设置swipecard
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v=inflater.inflate(R.layout.temp_user_status_info, container, false);
swipeCardsView=(SwipeCardsView)v.findViewById(R.id.swipeCard);
infoAdapter=new CurrentInfoAdapter(info,getActivity());
swipeCardsView.retainLastCard(false);
swipeCardsView.enableSwipe(true);
person_name=getArguments().getString("name");
person_people=getArguments().getString("people");
person_estimate=getArguments().getString("estimate");
CurrentInfo currentInfo=new CurrentInfo();
currentInfo.setName(person_name);
currentInfo.setPeople(person_people);
currentInfo.setEstimate(person_estimate);
Log.i("name",person_name);
Log.i("people",person_people);
Log.i("estimate",person_estimate);
info.add(currentInfo);
swipeCardsView.setAdapter(infoAdapter);
return v;
这是我将数据传递给SwipeCardView
的RecyclerView Adapter的代码@Override
public void onBindViewHolder(ViewHolder holder, int position) {
final CurrentEntry current=filterList.get(position);
// holder.number.setText(current.getNo());
holder.Name.setText(current.getName());
holder.People.setText(current.getPeople());
holder.Estimate.setText(current.getEstimate());
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String name=current.getName();
String people=current.getPeople();
String estimate=current.getEstimate();
Bundle args=new Bundle();
args.putString("name",name);
args.putString("people",people);
args.putString("estimate",estimate);
// UserSatusInfo satusInfo=new UserSatusInfo();
// satusInfo.setArguments(args);
TempUserStatusInfo info=new TempUserStatusInfo();
info.setArguments(args);
AppCompatActivity activity=(AppCompatActivity)v.getContext();
// activity.getSupportFragmentManager().beginTransaction().replace(R.id.frame,satusInfo).addToBackStack("info").commit();
activity.getSupportFragmentManager().beginTransaction().replace(R.id.frame,info).addToBackStack("info").commit();
Toast.makeText(v.getContext(),name,Toast.LENGTH_SHORT).show();
Log.i("name",name);
}
});
点击Recycclerview
中的任意一张卡后,如何同时获取所有卡片答案 0 :(得分:0)
您可以完整地传递arraylist
bundle.putSerializable("key", ArrayList<T extends Serializable> list);
然后在片段中接收
ArrayList<T extends Serializable> transactionList = (ArrayList<T extends Serializable>)getArguments().getSerializable("key");
希望这有帮助。