CopyPastor

Detecting plagiarism made easy.

Score: 2; Reported for: String similarity, Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2019-04-03
by Amit Desale

Original Post

Original - Posted on 2014-06-28
by nhaarman



            
Present in both answers; Present only in the new answer; Present only in the old answer;

As the API's have radically changed, It wouldn't surprise me if you were to create an `OnClickListener` for each item. It isn't that much of a hassle though. In your implementation of `RecyclerView.Adapter<MyViewHolder>`, you should have:
private final OnClickListener mOnClickListener = new MyOnClickListener();
@Override public MyViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) { View view = LayoutInflater.from(mContext).inflate(R.layout.myview, parent, false); view.setOnClickListener(mOnClickListener); return new MyViewHolder(view); }
The `onClick` method:
@Override public void onClick(final View view) { int itemPosition = mRecyclerView.getChildLayoutPosition(view); String item = mList.get(itemPosition); Toast.makeText(mContext, item, Toast.LENGTH_LONG).show(); }
As the API's have radically changed, It wouldn't surprise me if you were to create an `OnClickListener` for each item. It isn't that much of a hassle though. In your implementation of `RecyclerView.Adapter<MyViewHolder>`, you should have:
private final OnClickListener mOnClickListener = new MyOnClickListener();
@Override public MyViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) { View view = LayoutInflater.from(mContext).inflate(R.layout.myview, parent, false); view.setOnClickListener(mOnClickListener); return new MyViewHolder(view); }
The `onClick` method:
@Override public void onClick(final View view) { int itemPosition = mRecyclerView.getChildLayoutPosition(view); String item = mList.get(itemPosition); Toast.makeText(mContext, item, Toast.LENGTH_LONG).show(); }

        
Present in both answers; Present only in the new answer; Present only in the old answer;