在下面的嗨中,当我们从右侧拉出时,我实现了cardview,它显示了两个编辑/共享选项。现在,水平滚动视图也会激活。
如果我只向右拉出水平滚动视图,则只能显示不显示滑动选项。 我想刷卡视图时要显示水平滚动不想工作的编辑/共享选项
任何人都可以帮助我解决问题
public class ProposalAdapter extends RecyclerSwipeAdapter<ProposalAdapter.MyViewHolder> {
private LayoutInflater inflater;
private Context mContext;
private ArrayList<ModelTest> list;
private AccountAdapter.MyItemClickListener clickListener;
private boolean isScrollEnabled = true;
private AccountAdapter.MyEditItemClickListner editItemClickListner;
public ProposalAdapter(Context context, ArrayList<ModelTest> list) {
mContext = context;
this.list = list;
this.clickListener = clickListener;
this.editItemClickListner = editItemClickListner;
}
@Override
public ProposalAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Context context = parent.getContext();
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.fragment_nego, parent, false);
ProposalAdapter.MyViewHolder holder = new ProposalAdapter.MyViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(final ProposalAdapter.MyViewHolder holder, final int position) {
ModelTest opportunity=list.get(position);
holder.account_name.setText(opportunity.getRelated());
holder.potential_name.setText(opportunity.getPotentialValue());
holder.contact_name.setText(opportunity.getContact());
holder.potential_no.setText(opportunity.getPotentialNo());
holder.location.setText(opportunity.getLocation());
holder.item_name.setText(opportunity.getProductValue());
holder.amount.setText(opportunity.getValueAndQty());
holder.qty.setText(opportunity.getQty());
holder.win_prob.setText(opportunity.getWinprobValue());
holder.assigned_to.setText(opportunity.getAssigned());
String winProbePercent =opportunity.getWinprobValue();
if(winProbePercent.equals("30 %")){
holder.win_prob.setBackgroundColor(ContextCompat.getColor(mContext, R.color.orange));
} else if(winProbePercent.equals("50 %")){
holder.win_prob.setBackgroundColor(ContextCompat.getColor(mContext, R.color.orange));
} else if(winProbePercent.equals("80 %")){
holder.win_prob.setBackgroundColor(ContextCompat.getColor(mContext, R.color.green));
}
holder.sample1.setShowMode(SwipeLayout.ShowMode.PullOut);
holder.sample1.setDragEdge(SwipeLayout.DragEdge.Right);
holder.cardView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
holder.sample1.findViewById(R.id.share).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
whatsappIntent.setType("text/plain");
whatsappIntent.setPackage("com.whatsapp");
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_SUBJECT, "subject");
email.putExtra(Intent.EXTRA_TEXT, "text");
Uri uri = Uri.parse("file://" + email.getAction());
email.putExtra(Intent.EXTRA_STREAM, uri);
email.setType("message/rfc822");
mContext.startActivity(email);
whatsappIntent.putExtra(Intent.EXTRA_TEXT, "The text you wanted to share");
try {
mContext.startActivity(whatsappIntent);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(mContext,"Whatsapp have not been installed.",Toast.LENGTH_LONG).show();
}
}
});
}
@Override
public int getItemCount() {
return list.size();
}
@Override
public int getSwipeLayoutResourceId(int position) {
return R.id.sample1;
}
class MyViewHolder extends RecyclerView.ViewHolder {
TextView potential_name, account_name, contact_name,item_name,potential_no,amount,qty,location,win_prob,assigned_to;
Button email,pdf;
SwipeLayout sample1;
CardView cardView;
ImageView share,tvEdit;
LinearLayout cards;
ImageView image;
public MyViewHolder(View itemView) {
super(itemView);
sample1 = (SwipeLayout) itemView.findViewById(R.id.sample1);
image=(ImageView)itemView.findViewById(R.id.image);
share = (ImageView) itemView.findViewById(R.id.share);
tvEdit = (ImageView) itemView.findViewById(R.id.edit);
cardView = itemView.findViewById(R.id.cardView);
account_name = (TextView) itemView.findViewById(R.id.account_name);
potential_name = (TextView) itemView.findViewById(R.id.potential_name);
contact_name = (TextView) itemView.findViewById(R.id.contact_name);
item_name = (TextView) itemView.findViewById(R.id.item_name);
location = (TextView) itemView.findViewById(R.id.location);
potential_no = (TextView) itemView.findViewById(R.id.potential_no);
amount = (TextView) itemView.findViewById(R.id.amount);
win_prob = (TextView) itemView.findViewById(R.id.win_prob);
assigned_to= (TextView) itemView.findViewById(R.id.assigned_to);
qty = (TextView) itemView.findViewById(R.id.text_qty);
email = (Button) itemView.findViewById(R.id.email);
pdf = (Button) itemView.findViewById(R.id.pdf);
}
}