0

i have 2 xml files, one containing a recyclerview(main_fragment.xml) and another containing the items to render on that recyclerview(main_item.xml). my fragment(MainFragment.java) extends Fragment. main_item contains a textview. In MainFragment.java i am inflating main_fragment.xml. Now i want to reference the textview in main_item.xml so as to listen for a click. but i get a null pointer. I get that is because in MainFragment.java i am inflating main_fragment.xml and not main_item.xml. Pls where should should i setup the onClickListener for the textview in main_item.xml. Thanks

user3137376
  • 1,527
  • 2
  • 19
  • 29

1 Answers1

0

This needs to be done in you RecyclerView.Adapter and more specifically in the ViewHolder of the adapter.

There are many post on SO about that. RecyclerView onClick

Community
  • 1
  • 1
JDenais
  • 2,956
  • 2
  • 21
  • 30
  • i have this my viewHolder of my adapter, @Override public void onClick(View v) { //Toast.makeText(mContext, ParseTwitterUtils.getTwitter().getScreenName().toString(), Toast.LENGTH_SHORT).show(); } but that listens for click for each row on the list, not on items contained in that row – user3137376 Jul 02 '15 at 03:54