0
目前我設置imageview的點擊,即使在這樣的ViewHolder類:當我點擊裏面的imageview時,如何擺脫recyclerview項目的點擊?
public class HomeMenuViewHolder extends RecyclerView.ViewHolder implements View.OnLongClickListener, View.OnClickListener {
public ImageView imageView;
String[] tagBackgroundColors;
String[] tagBorderColors;
public HomeMenuViewHolder(View itemView, int viewType) {
super(itemView);
this.viewType = viewType;
imageView = (ImageView) itemView.findViewById(R.id.img_menu);
imageView.setOnClickListener(this);
}
@Override
public void onClick(View v) {
clickListener.onClick(getAdapterPosition(), false);
int id = v.getId();
if (id == R.id.cb_share_dday_show) {
CheckBox checkBox = (CheckBox) v;
if (checkBox.isChecked()) {
mPref.setShareDdayShow(Cons.TRUE);
} else {
mPref.setShareDdayShow(Cons.FALSE);
}
menuCallback.refreshFragments();
} else if (id == R.id.img_menu) {
showChangeColorDialog();
}
}
private void showChangeColorDialog() {
Dialog gridViewDialog = new Dialog(mContext);
gridViewDialog.setContentView(R.layout.dialog_change_color);
// You have to create the GridView object with gridViewDialog
GridView gv = ((GridView) gridViewDialog.findViewById(R.id.grid_change_color));
ChangeTagIconAdapter adapter = new ChangeTagIconAdapter(mContext, tagBackgroundColors, tagBorderColors);
gv.setAdapter(adapter);
gridViewDialog.show();
}
}
我把recyclerview導航抽屜內,recyclerview的項目的功能被關閉抽屜。我想要的是,當我點擊recyclerview內的imageview時,應該出現一個對話框而不關閉抽屜,但我總是可以點擊其中的recyclerview項目和imageview。請告訴我如何解決它。謝謝!
Inside onClick你檢查複選框是否被選中,但這個CheckBox的引用是在哪裏進入你的適配器? – Gorio
@Gorio我問的ImageView,而不是複選框,所以我刪除了一些不必要的代碼。 – Kakashi
您的代碼不完整,您能分享完整的代碼以嘗試幫助您嗎? – Gorio