title: Call a method from an activity from an adapter
body: <p>I am working with an adapter which has several buttons on each item of the ListView. I have, for example two buttons. One for save and another for delete. </p>
  
  <p>When I click on them, I want the adapter to refresh. I have a method on my activity that does that: Update the adapter. I made it since I couldn't make the Notify methods of the adapter work. </p>
  
  <p>I am sending the Activity to the adapter as a parameter and then call the update method from the adapter since I am setting the OnClick methods of each button in the adapter. </p>
  
  <p>The problem is that it doesnt seem to work always. I am guessing it has to do something about the cycle of the activity and Android cleaning memory however I can't seem to understand where is the problem.</p>
  
  <p>I am aware this is some ugly way of doing it, so what should be the best way of doing this?</p>
  
  <p>Summary: I need to refresh the adapter from the adapter itself when I delete an item of the ListView or update it (BaseAdapter)</p>
  
  <p>Edit:
  I am adding some code. This is my constructor of my adapter:</p>
  
  <pre><code>public SpendingPlanAdapter(Context context, SpendingPlan sp, int month, int year, money.activities.SpendingPlan act)
  </code></pre>
  
  <p>Inside the adapter I have an OnCLickListener attached to a button. I am calling the update method like this (Result is the result of a database insert):</p>
  
  <pre><code>if (result){
                      Toast.makeText(context, context.getResources().getString(R.string.succesfully_deleted), Toast.LENGTH_LONG).show();                  
                      act.updateAdapter();                    
                  } else {
                      Toast.makeText(context, context.getResources().getString(R.string.oops), Toast.LENGTH_LONG).show();}
  </code></pre>
  
  <p>And this is my UpdateAdapter method:</p>
  
  <pre><code>public void updateAdapter(){        
          SpendingPlanAdapter adapter = new SpendingPlanAdapter(getApplicationContext(), currentSp, currentMonth, currentYear, this);
          limitList.setAdapter(adapter);  
      }
  </code></pre>