This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Call Instance of View (Switch) located in Adapter's ViewHolder in the Activity that utilizes Adapter  RSS feed

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way for me to get an instance of the switch in my Adapter, in my Activity?

I created an instance of my Adapter's ViewHolder in my Activity:


Then I set up an onClickListener for the switch in my Activity's onCreate method:


However, I am getting a NullPointerException on the Switch. What am I missing?
 
Ranch Hand
Posts: 570
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean you want to use the switch in your Activity where the switch is declared in Adapter ?
 
Adam Wentz
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

John Joe wrote:You mean you want to use the switch in your Activity where the switch is declared in Adapter ?



Yes, the Switch is a View of the row layout for my RecyclerView. I want to be able to add an onClickListener to it in my Activity instead of doing it in the Adapter.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!