我有RecyclerView
显示数据列表。我想要做的是当用户点击该项目时,它会询问他们是否希望取消该用户的链接。我已经在应用程序的各个方面完成了这项工作,并且已根据功能齐全的RecyclerView
OnItemTouchListener
编写了此代码,但由于某种原因,拒绝注册任何点击是完全没有问题的。数据填充RecyclerView
罚款,它不会让我点击。我错过了一些明显的东西吗?
public void configurePage() {
Log.d(TAG, "test = " + listOfIDs.size());
mLayoutManager = new LinearLayoutManager(AgentViewUsers.this);
mAdapter = new AgentUserViewAdapter(listOfItems);
mRecyclerView.addOnItemTouchListener(new RecyclerTouchListener(getApplicationContext(), mRecyclerView, new RecyclerItemClickListener() {
@Override
public void onClick(View view, int position) {
AlertDialog.Builder build = new AlertDialog.Builder(AgentViewUsers.this);
build.setTitle("Unlink this user?");
build.setMessage("Are you sure you wish to unlink this user?");
build.setNegativeButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
// database code that deletes that user from firebase.
}
});
build.setPositiveButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
}
@Override
public void onLongClick(View view, int position) {
}
}));
mRecyclerView.addItemDecoration(new DividerItemDecoration(AgentViewUsers.this,DividerItemDecoration.VERTICAL_LIST));
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(mAdapter);
spinner.setVisibility(View.GONE);
// for loop that populates listOfItems from an already populated listOfIDs;
}
答案 0 :(得分:1)
好吧,你可能想在那个AlertDialog上调用show()。也许你正在使用列表项的自定义布局,并且该布局没有针对不同状态的不同drawable(即,按下,释放)