markeh21
markeh21

Reputation: 189

Android RecyclerView OnItemTouchListener not functioning

I have a RecyclerView showing a list of data. What I want to do is when the user taps on that item, it asks them if they wish to unlink that user. I have done this at various points in the application already and have written this code based on fully functioning RecyclerView OnItemTouchListener's, but for some reason this is flat out refusing to register any clicks. The data populates the RecyclerView fine, it will just not let me click. Have I missed something obvious?

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;
}

Upvotes: 0

Views: 384

Answers (1)

Alexandru Dascălu
Alexandru Dascălu

Reputation: 341

Well, you might wanna call show() on that AlertDialog. Also maybe you are using a custom layout for the list item and that layout doesn't have different drawables for different states (i.e. pressed, released)

Upvotes: 1

Related Questions