TrinityTuts Tips

Call Activity method inside adapter

This is simple and most common tip for every one because most of time we need to call a activity method inside adapter to pass data etc….

Try this to call inside adapter

 ((YourActivityName)mContext).customMethod();

If you are using same adapter in multiple activity you need to find instanceof and the call and specific method for the task like this:-

 if(mContext instanceof YourActivityName){
       ((YourActivityName)mContext).yourActivityMethod();
   }

🙂