You have a few options here:
- Pass
Context
as an argument to FeedAdapter and keep it as class field - Use dependency injection to inject
Context
when you need it. I strongly suggest reading about it. There is a great tool for that — Dagger by Square Get it from any
View
object. In your case this might work for you:holder.pub_image.getContext()
As
pub_image
is aImageView
.
Related Contents:
- Recyclerview painfully slow to load cached images form Picasso
- How to create RecyclerView with multiple view types
- RecyclerView onClick
- Using context in a fragment
- Why doesn’t RecyclerView have onItemClickListener()?
- How to display data from Firestore in a RecyclerView with Android?
- Android 5.0 – Add header/footer to a RecyclerView
- Android RecyclerView addition & removal of items
- How to add a recyclerView inside another recyclerView
- Why is adding an OnClickListener inside onBindViewHolder of a RecyclerView.Adapter considered bad practice?
- RecyclerView Item Click Listener the Right Way
- Is there a way to paginate queries by combining query cursors using FirestoreRecyclerAdapter?
- getString Outside of a Context or Activity
- How to scroll to the bottom of a RecyclerView? scrollToPosition doesn’t work
- RecyclerView – Get view at particular position
- Android RecyclerView Scrolling Performance
- LinearLayoutManager setReverseLayout() == true but items stack from bottom
- Recyclerview not call onCreateViewHolder
- Get application context from non activity singleton class
- App crashing when trying to use RecyclerView on android 5.0
- RecyclerView not calling onCreateViewHolder or onBindView
- Divide elements on groups in RecyclerView or Grouping Recyclerview items ,say by date
- How to listen for Picasso (Android) load complete events?
- Recyclerview not call any Adapter method :onCreateViewHolder,onBindViewHolder,
- com.android.build.transform.api.TransformException
- How to make an Android device vibrate? with different frequency?
- How to Ping External IP from Java Android
- Android Thread for a timer
- How can I get Android Wifi Scan Results into a list?
- How to deserialise a subclass in Firebase using getValue(Subclass.class)
- JSON Parsing in Android [duplicate]
- How can one detect airplane mode on Android?
- How to escape % in String.Format?
- Android/Java — Post simple text to Facebook wall?
- Universal way to write to external SD card on Android
- Variable cannot be resolved
- What’s a good library for parsing mathematical expressions in java? [closed]
- Android How to listen for Volume Button events?
- Writing a file to sdcard
- Access resource files in Android
- How to draw a filled triangle in android canvas?
- java – ignore expired ssl certificate
- android.content.res.Resources$NotFoundException
- Android Center text on canvas
- What is the Simplest Way to Reverse an ArrayList?
- NullPointerException on Button.findViewById()
- android color between two colors, based on percentage?
- ActivityCompat.requestPermissions not showing dialog box
- Change DecimalFormat locale
- MediaPlayer.setDataSource(String) not working with local files