Привет в приведенном ниже screnerio хотите, чтобы сместить ontouch для textviewoptions. Значит, если щелкнуть по textviewoptions хотят показать две опции редактирования и поделиться опцией.
если я нажимаю на onch хочу показать всплывающее окно.
Но с приведенным ниже кодом это происходит для обеих текстовых опций, также показывающих всплывающее окно. Я не хочу показывать всплывающее окно, когда кликните по текстовым опциям, хотите показать только опции редактирования и поделиться
В приведенном ниже адаптере содержится Меню textviewoptions содержит два пункта меню, один из которых является общим, а другой - редактируемым.
TaskAdapter. java:
holder.textViewOptions.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
holder.textViewOptions.setClickable(true);
PopupMenu popupMenu=new PopupMenu(mContext,holder.textViewOptions);
popupMenu.inflate(R.menu.menu_card);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.edit:
break;
case R.id.share:
if (!isClickable){
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, true);
sendIntent.setType("text/plain");
Intent.createChooser(sendIntent, "Share via");
mContext.startActivity(sendIntent);
return true;
}
}
return false;
}
});
popupMenu.show();
}
});
ниже fragement содержит обзор переработчика для на сенсорном листинге
TaskFragment. java:
recyclerViewTask.addOnItemTouchListener(new RecyclerTouchListener(getContext(), recyclerViewTask, new RecyclerTouchListener.ClickListener() {
@Override
public void onClick(View view, int position) {
String subject_name = listTask.get(position).getSubject();
String task_types = listTask.get(position).getTaskType();
String assigneds = listTask.get(position).getAssigned();
String scheduledates = listTask.get(position).getScheduleDate();
String locations = listTask.get(position).getLocation();
String opportunityNos = listTask.get(position).getOpportunityNo();
String statuss = listTask.get(position).getStatus();
String outcomes = listTask.get(position).getOutcome();
String created_time = listTask.get(position).getCreatedtime();
String modified_time = listTask.get(position).getModifiedtime();
String activity_type = listTask.get(position).getActivitytype();
String modified_by = listTask.get(position).getModifiedby();
String remarks = listTask.get(position).getRemark();
LayoutInflater layoutInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View customView = layoutInflater.inflate(R.layout.custom_popup_task, null);
linearLayout = customView.findViewById(R.id.card_details);
final PopupWindow popupWindow = new PopupWindow(customView,
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT,
true);
popupWindow.setFocusable(true);
popupWindow.showAtLocation(customView, Gravity.CENTER, 0, 0);
subject = (TextView) customView.findViewById(R.id.subject);
outcome = (TextView) customView.findViewById(R.id.outcome);
status = (TextView) customView.findViewById(R.id.status);
task_type = (TextView) customView.findViewById(R.id.task_type);
assigned_to = (TextView) customView.findViewById(R.id.assigned_to);
related_to = (TextView) customView.findViewById(R.id.related_to);
schedule_date = (TextView) customView.findViewById(R.id.schedule_date);
location = (TextView) customView.findViewById(R.id.location);
opportunity = (TextView) customView.findViewById(R.id.opp_no);
createdtime = (TextView) customView.findViewById(R.id.createdtime);
modifiedtime = (TextView) customView.findViewById(R.id.modifiedtime);
modifiedby = (TextView) customView.findViewById(R.id.modifiedby);
activitytype = (TextView) customView.findViewById(R.id.activitytype);
remark = (TextView) customView.findViewById(R.id.remark);
image = (ImageView) customView.findViewById(R.id.image);
closebtn = (Button) customView.findViewById(R.id.close);
subject.setText(subject_name);
outcome.setText(outcomes);
status.setText(statuss);
task_type.setText(task_types);
assigned_to.setText(assigneds);
schedule_date.setText(scheduledates);
location.setText(locations);
opportunity.setText(opportunityNos);
createdtime.setText(created_time);
modifiedtime.setText(modified_time);
modifiedby.setText(modified_by);
activitytype.setText(activity_type);
remark.setText(remarks);
if (statuss.equals("Scheduled")) {
status.setBackgroundResource(R.color.orange);
} else if (statuss.equals("Completed")) {
status.setBackgroundResource(R.color.green);
} else if (statuss.equals("In Complete")) {
status.setBackgroundResource(R.color.red);
}
if (outcomes.equals(" Follow-up ")) {
image.setImageResource(R.drawable.followup);
image.setColorFilter(ContextCompat.getColor(getContext(), R.color.linecolor));
} else if (outcomes.equals(" Order Closed ")) {
image.setImageResource(R.drawable.orderclosed);
image.setColorFilter(ContextCompat.getColor(getContext(), R.color.linecolor));
} else if (outcomes.equals(" Interested ")) {
image.setImageResource(R.drawable.ic_thumb_up_black_24dp);
} else if (outcomes.equals(" Done ")) {
image.setImageResource(R.drawable.done);
image.setColorFilter(ContextCompat.getColor(getContext(), R.color.linecolor));
} else if (outcomes.equals(" Collected ")) {
image.setImageResource(R.drawable.collected);
image.setColorFilter(ContextCompat.getColor(getContext(), R.color.linecolor));
} else if (outcomes.equals(" Not Interested ")) {
image.setImageResource(R.drawable.ic_thumb_down_black_24dp);
}
closebtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popupWindow.dismiss();
}
});
}
@Override
public void onLongClick (View view,int position){
}
}));