title: Need to detect click and touch event on my RecyclerView with row detection
body: <p>I've tried to set up a click and toch listener for my RecyclerView with tutorials. But every tutorial I've tried I finaly failed because I've set the RecyclerView up with an other tutorial and all tutorials are looking different. Please can you help me detect click for each row? For example when a user clicks my first row (which is a logout field) it should logout the user from the app. All of my logout actions are working but the click on RecyclerView don't.</p>
  
  <p>My SettingsAdapter:</p>
  
  <pre><code>import android.content.DialogInterface;
  import android.os.Bundle;
  import android.support.v7.app.AlertDialog;
  import android.support.v7.widget.RecyclerView;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ImageView;
  import android.widget.RelativeLayout;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import java.util.List;
  
  /**
   * Created by Johannes on 19.01.2017.
   */
  
  public class SettingsAdapter extends RecyclerView.Adapter&lt;SettingsAdapter.MySettingHolder&gt; {
  
      private List&lt;Settings&gt; settingList;
  
      public class MySettingHolder extends RecyclerView.ViewHolder {
          public ImageView settingImage;
          public TextView settingTitle, settingSubtitle;
  
          public MySettingHolder(View view) {
              super(view);
              settingImage = (ImageView) view.findViewById(R.id.settingImage);
              settingTitle = (TextView) view.findViewById(R.id.settingTitle);
              settingSubtitle = (TextView) view.findViewById(R.id.settingSubtitle);
          }
      }
  
      public SettingsAdapter (List&lt;Settings&gt; settingList) {
          this.settingList = settingList;
      }
  
      @Override
      public MySettingHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View itemView = LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.settings_list_row, parent, false);
  
          return new MySettingHolder(itemView);
      }
  
      @Override
      public void onBindViewHolder(MySettingHolder holder, int position) {
          // Setting for one entry
          Settings setting = settingList.get(position);
  
          holder.settingImage.setImageResource(setting.getSettingImageUrl());
          // If the settingSubtitle is empty it should be not visible and just the settingTitle
          if (setting.getSettingSubtitle().equals("")) {
              holder.settingTitle.setText(setting.getSettingTitle());
              holder.settingSubtitle.setVisibility(View.GONE);
          } else {
              holder.settingTitle.setText(setting.getSettingTitle());
              holder.settingSubtitle.setText(setting.getSettingSubtitle());
          }
      }
  
      @Override
      public int getItemCount() {
          return settingList.size();
      }
  
  }
  </code></pre>
  
  <p>This is my SettingsFragment where I implement the RecyclerView</p>
  
  <pre><code>import android.app.AlertDialog;
  import android.content.Context;
  import android.content.DialogInterface;
  import android.content.Intent;
  import android.content.SharedPreferences;
  import android.net.Uri;
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.support.v7.widget.DefaultItemAnimator;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.RecyclerView;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.Button;
  import android.widget.CalendarView;
  import android.widget.TextView;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import static android.content.Context.MODE_PRIVATE;
  
  /**
   * A simple {@link Fragment} subclass.
   * Activities that contain this fragment must implement the
   * {@link SettingsFragment.OnFragmentInteractionListener} interface
   * to handle interaction events.
   * Use the {@link SettingsFragment#newInstance} factory method to
   * create an instance of this fragment.
   */
  public class SettingsFragment extends Fragment {
      // Variables
      private OnFragmentInteractionListener mListener;
      // Variables for Recycler View
      private List&lt;Settings&gt; settingList = new ArrayList&lt;&gt;();
      private RecyclerView accountRecyclerView;
      private SettingsAdapter aAdapter;
  
      public SettingsFragment() {
          // Required empty public constructor
      }
  
      //Change the title in action bar
      public void onResume(){
          super.onResume();
          String titleString = getResources().getString(R.string.title_activity_navigation_drawer_settings);
          // Set title bar
          ((NavigationDrawerActivity) getActivity())
                  .setActionBarTitle(titleString);
      }
  
      public static SettingsFragment newInstance() {
          SettingsFragment fragment = new SettingsFragment();
          return fragment;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
          View view  =  inflater.inflate(R.layout.fragment_settings, container, false);
  
          accountRecyclerView = (RecyclerView) view.findViewById(R.id.account_recycler_view);
  
          aAdapter = new SettingsAdapter(settingList);
          RecyclerView.LayoutManager aLayoutManager = new LinearLayoutManager(getActivity().getApplicationContext()) {
              // Disable scrolling in the RecyclerView
              @Override
              public boolean canScrollVertically() {
                  return false;
              }
          };
  
          // Setup account RecyclerView
          accountRecyclerView.setLayoutManager(aLayoutManager);
          accountRecyclerView.setItemAnimator(new DefaultItemAnimator());
          prepareAccountData();
          accountRecyclerView.setAdapter(aAdapter);
  
          return view;
      }
  
      private void prepareAccountData() {
          // Create new setting
          Settings setting = new Settings(R.drawable.ic_menu_logout, "Abmelden", "Deine Daten bleibe erhalten");
          // Add Object to list
          settingList.add(setting);
  
          // Notify data changes
          aAdapter.notifyDataSetChanged();
      }
  
      // TODO: Rename method, update argument and hook method into UI event
      public void onButtonPressed(Uri uri) {
          if (mListener != null) {
              mListener.onFragmentInteraction(uri);
          }
      }
  
      @Override
      public void onAttach(Context context) {
          super.onAttach(context);
      }
  
      @Override
      public void onStart() {
          super.onStart();
  
          try {
              mListener = (OnFragmentInteractionListener) getActivity();
          } catch (ClassCastException e) {
              throw new ClassCastException(getActivity().toString()
                      + " must implement OnFragmentInteractionListener");
          }
  
      }
  
      @Override
      public void onDetach() {
          super.onDetach();
          mListener = null;
      }
  
      /**
       * This interface must be implemented by activities that contain this
       * fragment to allow an interaction in this fragment to be communicated
       * to the activity and potentially other fragments contained in that
       * activity.
       * &lt;p&gt;
       * See the Android Training lesson &lt;a href=
       * "http://developer.android.com/training/basics/fragments/communicating.html"
       * &gt;Communicating with Other Fragments&lt;/a&gt; for more information.
       */
      public interface OnFragmentInteractionListener {
          // TODO: Update argument type and name
          void onFragmentInteraction(Uri uri);
      }
  }
  </code></pre>