0

I have a recyclerView that contains a TextView and I want to access that TextView from another activity, by using the normal findViewById method as shown below, but I get:

NullPointerException: Attempt to invoke virtual method 
'android.view.View android.view.View.findViewById(int)'
on a null object reference "ChordName = findViewById(R.id.textView);
Martin Zeitler
  • 1
  • 19
  • 155
  • 216
JadLu
  • 72
  • 1
  • 8
  • 1
    You must use adapter for ReyclerView. Than, you can use it. – AlpYuktug Sep 08 '19 at 18:34
  • I do use an adapter, can you show me how please ?? – JadLu Sep 08 '19 at 18:43
  • 1
    Possible duplicate of [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – Martin Zeitler Sep 08 '19 at 19:11
  • you can only access it from Parent Activity and you would still need to implement an "interface" for that – Shahin Sep 08 '19 at 20:14
  • I think what you want to do is send the data using intent from your other activity. Can you share your code please? – The_Martian Sep 08 '19 at 23:45
  • No, i want to edit the textview of the recyclerView, and sometimes set their visibility to FALSE. – JadLu Sep 09 '19 at 00:14
  • That's not recommended because it would lead to nasty memory leak that would happen when your code is trying to access the activity android OS has destroyed for any reason. Besides that you will have very hard to test coupled code. Your implementation sounds bad IMHO. – The_Martian Sep 09 '19 at 20:32
  • Ok I see, that's what I thought. Thank's anyway. – JadLu Sep 09 '19 at 20:51

0 Answers0