Reputation: 347
In main activity, cast Recyclerview like
Recyclerview mylist=(Recyclerview)findviewbyid(R.ID.rv);
But i need to handle this Recyclerview from my NetworkBroadcast class which extends service class So i tried
Recyclerview mylist=(Recyclerview)((Activity)mcontext)findviewbyid(R.ID.rv);
Its not work
Upvotes: 0
Views: 116
Reputation: 548
That won't work for you.
Because, service classes are without View. You cannot have XML for your service class.
From the documentation:
A Service is an application component that can perform long-running operations in the background, and it doesn't provide a user interface.
To handle your recyclerView in View(Activity/Fragment) from any other class (in your case from NetworkBroadcast class), you need to use interface.
Upvotes: 1