Sunday, February 17, 2013

Android Activity method from the adapter class

Android Activity method from the adapter class

Below the example for how to call activity method from adapter class.

Some time I try to call activity method from base adapter or adapter class but I unable to call this method or I am getting some error. So finally I got the solution .
Below the code
Create Interface Class 

public interface RefreshInterface {
public void refresh();

Then implement this interface to your activity class.

    public void onCreate(Bundle savedInstanceState) {

MyArrayAdapter myAdapter = new MyArrayAdapter(getApplicationContext(), R.layout.appsview_item, List, new RefreshInterface () {
                  public void refresh() {
          //do something here
Call activity method from adapter class

public class MyArrayAdapterextends ArrayAdapter<Structure> {

RefreshInterface intr;
public MyArrayAdapter(Context context, int textViewResourceId,
                  List<App> objects, RefreshInterface refreshInt) {
            super(context, textViewResourceId, objects);
            intr = refreshInt;

public View getView(final int position, View appView, ViewGroup parent) {

//this is your activity method




  1. We stumbled over here different web address and
    thought I may as well check things out. I like what I see so now i am following you.
    Look forward to looking at your web page again.

    Here is my homepage: Bathroom Sinks
    my site -

  2. Hi, I think your site might be having browser compatibility issues.
    When I look at your website
    in Safari, it looks fine but when opening in Internet
    Explorer, it has some overlapping. I just wanted to give you a
    quick heads up! Other then that, fantastic blog!

  3. Thank уou for the аuspicious writeup. It in faсt was a amusement account it.

    Look advanced to mοгe aԁdeԁ agreeable frοm yοu!
    By the way, how сould we communicаte?

    Feel free to surf tο my blοg post; keyword


Check out this may be help you

Related Posts Plugin for WordPress, Blogger...