我正在開發中,我想從API來的價格進行排序, 1.低到高 2.高至低排序RecyclerView Accending/Decending訂購其價值
的應用程序是在recylerView任何方法按照加入和減少的順序排列項目。
這是我的適配器OnBindViewHolder方法:
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
typeface = Typeface.createFromAsset(context.getAssets(),"fonts/Raleway-SemiBold.ttf");
String email = doctorList.get(position).getDoctor().getDoctor_email();
doctor_id = doctorList.get(position).getDoctor().getDoctor_id();
holder.dr_name.setText(doctorList.get(position).getDoctor().getDoctor_name());
holder.dr_exp.setText(doctorList.get(position).getDoctor().getDoctor_exp()+" exp.");
holder.dr_fee.setText("Rs. "+doctorList.get(position).getDoctor().getDoctor_fee());
Log.e("FEE",""+doctorList.get(position).getDoctor().getDoctor_fee());
// holder.dr_imageDL.setImageURI(Uri.parse(doctorList.get(position).getDoctor().getDoctor_img()));
Picasso.with(context)
.load(doctorList.get(position).getDoctor().getDoctor_img())
.memoryPolicy(MemoryPolicy.NO_CACHE)
.networkPolicy(NetworkPolicy.NO_CACHE)
.resize(200, 200)
.placeholder(R.drawable.doctor_img)
.into(holder.dr_imageDL);
holder.bookBtn.setTypeface(typeface);
holder.bookBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(view.getContext(), BookAppointment.class);
intent.putExtra("DOCTOR_ID",doctor_id);
view.getContext().startActivity(intent);
Log.e("CLICK","CLICK"+doctor_id);
}
});
}
爲什麼不ü列表進行排序和重新填充回收者視圖? – Moulesh
我怎麼樣,請告訴我@Moulesh –
您想根據價格對您的清單數據進行排序嗎? – Moulesh