Hi,
my code is the exact same as my book and android studio is complaining it cant resolve onClickListener
heres my code if thats any help.
private class CrimeHolder extends RecyclerView.ViewHolder implements View.onClickListener // cant resolve it for some reason..
{
private TextView mTitleTextView;
private TextView mDateTextView;
private Crime mCrime;
@Override // method does not overide from its superclass
public void onClick(View view){
Toast.makeText(getActivity(),mCrime.getTitle()+ "Clicked!", Toast.LENGTH_SHORT).show();
}
public void bind(Crime crime){
mCrime =crime;
mTitleTextView.setText(mCrime.getTitle());
mDateTextView.setText(mCrime.getDate().toString());
}
public CrimeHolder(LayoutInflater inflater, ViewGroup parent){
super(inflater.inflate(R.layout.list_item_crime, parent, false));
itemView.setOnClickListener(this); // cannot be applied to (this)
mTitleTextView = (TextView)
itemView.findViewById(R.id.crime_title);
mDateTextView = (TextView)
itemView.findViewById(R.id.crime_date);
}
}