title: How to pass value from recyclerview item to another activity
body: <p>I'm trying to pass the value in recyclerview item to another activity when we click the recyclerview item. Here I use the <code>OnItemTouchListener</code>.</p>
  
  <p>I retrieve data from JSON and parse it into ArrayList. I save 5 parameters. Title, ID, Rating, ReleaseDate, urlPoster, but right now i only show 2 parameters, Title, and image from urlposter.</p>
  
  <p>I want to pass the other parameters to another activity, but i can't find out how to do that. </p>
  
  <p>There's another question similar like this (<a href="https://stackoverflow.com/questions/31496177/values-from-recyclerview-item-to-other-activity">Values from RecyclerView item to other Activity</a>), but he uses OnClick, not OnItemTouch, and he do that in the ViewHolder. I read somewhere in the internet that it's not the right thing to do.</p>
  
  <p>Here's my code</p>
  
  <pre><code>public class Tab1 extends Fragment {
  
      private static final String ARG_PAGE = "arg_page";
      private static final String STATE_MOVIES = "state movies";
      private TextView txtResponse;
      private String passID;
  
      // Progress dialog
      private ProgressDialog pDialog;
  
  
      //private String urlJsonArry = "http://api.androidhive.info/volley/person_array.json";
      private String urlJsonArry = "http://api.themoviedb.org/3/movie/popular?api_key=someapikeyhere";
      private String urlJsonImg = "http://image.tmdb.org/t/p/w342";
  
      // temporary string to show the parsed response
      private String jsonResponse = "";
  
      RecyclerView mRecyclerView;
      RecyclerView.LayoutManager mLayoutManager;
      RecyclerView.Adapter mAdapter;
  
      private ArrayList&lt;Movies&gt; movies = new ArrayList&lt;Movies&gt;();
  
  
      public Tab1() {
          // Required empty public constructor
      }
  
      @Override
      public void onSaveInstanceState(Bundle outState) {
          super.onSaveInstanceState(outState);
          outState.putParcelableArrayList(STATE_MOVIES, movies);
      }
  
      public static Tab1 newInstance(int pageNumber){
  
          Tab1 myFragment = new Tab1();
          Bundle arguments = new Bundle();
          arguments.putInt(ARG_PAGE, pageNumber);
          myFragment.setArguments(arguments);
          return myFragment;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
  
  
          pDialog = new ProgressDialog(getActivity());
          pDialog.setMessage("Please wait...");
          pDialog.setCancelable(false);
      }
  
  
      /**
       * Method to make json object request where json response starts wtih {
       * */
      private void makeJsonObjectRequest() {
  
          showpDialog();
  
          final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(urlJsonArry, new Response.Listener&lt;JSONObject&gt;() {
  
  
              @Override
              public void onResponse(JSONObject response) {
                  //Log.d(TAG, response.toString());
  
                  try {
  
                      JSONArray result = response.getJSONArray("results");
  
                      //Iterate the jsonArray and print the info of JSONObjects
                      for(int i=0; i &lt; result.length(); i++){
                          JSONObject jsonObject = result.getJSONObject(i);
  
                          String id = jsonObject.getString("id");
                          String originalTitle = jsonObject.getString("original_title");
                          String releaseDate = jsonObject.getString("release_date");
                          String rating = jsonObject.getString("vote_average");
                          String urlThumbnail = urlJsonImg + jsonObject.getString("poster_path");
  
                          //jsonResponse = "";
                          jsonResponse += "ID: " + id + "\n\n";
                          jsonResponse += "Title: " + originalTitle + "\n\n";
                          jsonResponse += "Release Date: " + releaseDate + "\n\n";
                          jsonResponse += "Rating: " + rating + "\n\n";
                  }
                      //Toast.makeText(getActivity(),"Response = "+jsonResponse,Toast.LENGTH_LONG).show();
                      parseResult(response);
  
                  }catch (JSONException e) {
                      e.printStackTrace();
                      Toast.makeText(getActivity(),"Error: " + e.getMessage(),
                              Toast.LENGTH_LONG).show();
                  }
                  hidepDialog();
              }
          }, new Response.ErrorListener() {
  
              @Override
              public void onErrorResponse(VolleyError error) {
                  //VolleyLog.d(TAG, "Error: " + error.getMessage());
                  Toast.makeText(getActivity(),
                          error.getMessage(), Toast.LENGTH_SHORT).show();
                  // hide the progress dialog
                  hidepDialog();
              }
          });
  
          // Adding request to request queue
          VolleySingleton.getInstance(getActivity()).addToRequestQueue(jsonObjectRequest);
      }
  
  
      private void showpDialog() {
          if (!pDialog.isShowing())
              pDialog.show();
      }
  
      private void hidepDialog() {
          if (pDialog.isShowing())
              pDialog.dismiss();
      }
  
      @Override
      public void onActivityCreated(Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
  
          //txtResponse = (TextView) getActivity().findViewById(R.id.txtResponse);
          //makeJsonArrayRequest();
  
          // Calling the RecyclerView
          mRecyclerView = (RecyclerView) getActivity().findViewById(R.id.recycler_view_movie);
          mRecyclerView.setHasFixedSize(true);
  
          // The number of Columns
          mLayoutManager = new GridLayoutManager(getActivity(),2);
          mRecyclerView.setLayoutManager(mLayoutManager);
  
          mAdapter = new MovieAdapter(getActivity(),movies);
          mRecyclerView.setAdapter(mAdapter);
  
          mRecyclerView.addOnItemTouchListener(new RecyclerTouchListener(getActivity(), mRecyclerView, new ClickListener() {
              @Override
              public void onMovieClick(View view, int position) {
                  Toast.makeText(getActivity(), "Kepencet " + position, Toast.LENGTH_SHORT).show();
  
                  **//what to do here?**
              }
  
              @Override
              public void onMovieLongClick(View view, int position) {
                  Toast.makeText(getActivity(),"Kepencet Lama "+position,Toast.LENGTH_LONG).show();
              }
          }));
  
          makeJsonObjectRequest();
  
          if (savedInstanceState!=null){
              movies=savedInstanceState.getParcelableArrayList(STATE_MOVIES);
              mAdapter.notifyDataSetChanged();
          }
      }
  
  
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          // Inflate the layout for this fragment
          View view =  inflater.inflate(R.layout.tab_1, container, false);
  
  
          return view;
      }
  
      private void parseResult(JSONObject response) {
          try {
              JSONArray arrayMovies = response.getJSONArray("results");
  
  
              if (movies == null) {
                  movies = new ArrayList&lt;Movies&gt;();
              }
  
  
  
              for (int i = 0; i &lt; arrayMovies.length(); i++) {
  
                  JSONObject currentMovies = arrayMovies.getJSONObject(i);
  
                  Movies item = new Movies();
                  item.setTitle(currentMovies.optString("original_title"));
                  item.setRating(currentMovies.optString("vote_average"));
                  item.setReleaseDate(currentMovies.optString("release_date"));
                  item.setId(currentMovies.optString("id"));
                  item.setUrlThumbnail(urlJsonImg+currentMovies.optString("poster_path"));
                  movies.add(item);
                  mAdapter.notifyDataSetChanged();
  
                  //Toast.makeText(getActivity(),"Movie : "+movies,Toast.LENGTH_LONG).show();
              }
          } catch (JSONException e) {
              e.printStackTrace();
          }
      }
  
      class RecyclerTouchListener implements RecyclerView.OnItemTouchListener{
          private GestureDetector mGestureDetector;
          private ClickListener mClickListener;
  
  
          public RecyclerTouchListener(final Context context, final RecyclerView recyclerView, final ClickListener clickListener) {
              this.mClickListener = clickListener;
              mGestureDetector = new GestureDetector(context,new GestureDetector.SimpleOnGestureListener(){
                  @Override
                  public boolean onSingleTapUp(MotionEvent e) {
                      return true;
                  }
  
                  @Override
                  public void onLongPress(MotionEvent e) {
                      View child = recyclerView.findChildViewUnder(e.getX(),e.getY());
                      if (child!=null &amp;&amp; clickListener!=null){
                          clickListener.onMovieLongClick(child,recyclerView.getChildAdapterPosition(child));
                      }
                      super.onLongPress(e);
                  }
              });
          }
  
          @Override
          public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
              View child = rv.findChildViewUnder(e.getX(), e.getY());
              if (child!=null &amp;&amp; mClickListener!=null &amp;&amp; mGestureDetector.onTouchEvent(e)){
                  mClickListener.onMovieClick(child,rv.getChildAdapterPosition(child));
              }
              return false;
          }
  
          @Override
          public void onTouchEvent(RecyclerView rv, MotionEvent e) {
  
          }
  
          @Override
          public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
  
          }
      }
  
      public static interface ClickListener{
          public void onMovieClick(View view, int position);
          public void onMovieLongClick(View view, int position);
      }
  
  }
  </code></pre>
  
  <p>any help would be appreciated. Thanks!</p>