Want to update the getView method, when using a GridView
<p>I'm using a baseadapter class for my calender in which it populates the calender with icons corresponding to the data in the database. However I want the code within the getView to update whenever a user clicks on the calender, therefore showing a new icon immediately. How do I do this without creating a new instance of the baseAdapter class?</p>

<p>Here is my baseAdapter class:</p>

<pre><code>import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;



import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class CalendarAdapter extends BaseAdapter {
static final int FIRST_DAY_OF_WEEK =0; 

private String month2;
private Context mContext;

private java.util.Calendar month; 
private Calendar selectedDate;
private ArrayList&lt;String&gt; items;
private List&lt;String&gt; songArray = new ArrayList&lt;String&gt;();




public CalendarAdapter(Context c, Calendar monthCalendar, Long EXTRAS) {

    month = monthCalendar;
    selectedDate = (Calendar)monthCalendar.clone();
    mContext = c;
    month.set(Calendar.DAY_OF_MONTH, 1);
    this.items = new ArrayList&lt;String&gt;();

    songArray =new ArrayList&lt;String&gt;();



    DatabaseRecords info2 = new DatabaseRecords(mContext);      
    info2.open();   
    for(int i=0; i &lt; info2.getSpecificIDTask(EXTRAS).size(); i++){
        songArray = info2.getSpecificIDTask(EXTRAS);
        Log.d("Database already contains", songArray.get(i));   
    }
    info2.close();

    refreshDays();




}


public void iconUpdate(){

}




public void setItems(ArrayList&lt;String&gt; items) {


    /////Insert Database Records into ITEMS LIST
    int i;
    for(i=0;i&lt;songArray.size();i++)
    {
        items.add(songArray.get(i));
    }


    /////FOR ALL ITEMS ADDED INTO ITEMS OUTPUT
    int j;
    for(j=0; j&lt;items.size();j++)
    {
        Log.d("ITEMS ARRAYLIST CONTAINS", items.get(j));
    }

    this.items=items;
}



public int getCount() {
    return days.length;
}

public Object getItem(int position) {
    return null;
} 

public long getItemId(int position) {
    return 0;
}

// create a new view for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    TextView dayView;
    if (convertView == null) {  // if it's not recycled, initialize some attributes
        LayoutInflater vi = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(R.layout.calendar_item, null);

    }
    dayView = (TextView)v.findViewById(R.id.date);

    // disable empty days from the beginning
    if(days[position].equals("")) {
        dayView.setClickable(false);
        dayView.setFocusable(false);
    }
    else {
        // mark current day as focused
        if(month.get(Calendar.YEAR)== selectedDate.get(Calendar.YEAR) &amp;&amp; month.get(Calendar.MONTH)== selectedDate.get(Calendar.MONTH) &amp;&amp; days[position].equals(""+selectedDate.get(Calendar.DAY_OF_MONTH))) {
            v.setBackgroundResource(R.drawable.item_background_focused);
        }
        else {
            v.setBackgroundResource(R.drawable.list_item_background);
        }
    }
    dayView.setText(days[position]);

    // create date string for comparison
    String date = days[position];

    if(date.length()==1) {
        date = "0"+date;
    }
    String monthStr = ""+(month.get(Calendar.MONTH)+1);
    if(monthStr.length()==1) {
        monthStr = "0"+monthStr;
    }


    //OUTPUT ALL DATES IN THIS MONTH
    String temp;
    temp = month.get(Calendar.YEAR) + "-" +  month.get(Calendar.MONTH) + "-" + date;
    Log.d("THIS MONTH CONTAINS", temp);

    //OUTPUT SIZE OF ITEMS 
    Log.d("SIZE", ""+items.size());
    int j;
    for(j=0; j&lt;items.size();j++)
    {
        Log.d("ARRAY3", items.get(j));
    }

    // show icon if date is not empty and it exists in the items array
    ImageView iw = (ImageView)v.findViewById(R.id.date_icon);
    if(items.contains(temp)) {    

        iw.setVisibility(View.VISIBLE);
            } 
         else {
                iw.setVisibility(View.INVISIBLE);

    }


  //        
 // }
        /*
    ImageView iw = (ImageView)v.findViewById(R.id.date_icon);
    Log.d("DAYSOFMONTH",month.get(Calendar.YEAR) + "-" +  month.get(Calendar.MONTH) + "-" + date);

    String temp;
    temp = month.get(Calendar.YEAR) + "-" +  month.get(Calendar.MONTH) + "-" + date;

 */

    return v;
}

public void refreshDays()
{
    // clear items
    items.clear();

    int lastDay = month.getActualMaximum(Calendar.DAY_OF_MONTH);
    int firstDay = (int)month.get(Calendar.DAY_OF_WEEK);

    // figure size of the array
    if(firstDay==1){
        days = new String[lastDay+(FIRST_DAY_OF_WEEK*6)];
    }
    else {
        days = new String[lastDay+firstDay-(FIRST_DAY_OF_WEEK+1)];
    }

    int j=FIRST_DAY_OF_WEEK;

    // populate empty days before first real day
    if(firstDay&gt;1) {
        for(j=0;j&lt;firstDay-FIRST_DAY_OF_WEEK;j++) {
            days[j] = "";
        }
    }
    else {
        for(j=0;j&lt;FIRST_DAY_OF_WEEK*6;j++) {
            days[j] = "";
        }
        j=FIRST_DAY_OF_WEEK*6+1; // sunday =&gt; 1, monday =&gt; 7
    }

    // populate days
    int dayNumber = 1;
    for(int i=j-1;i&lt;days.length;i++) {
        days[i] = ""+dayNumber;
        dayNumber++;
    }
}

// references to our items
public String[] days;
</code></pre>

<p>}</p>

<p>Here is the class calling the baseAdapter class, I want to update the baseAdapter class in the onclick method: </p>

<pre><code>package com.example.motivation;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Random;


import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.TextView;
import android.widget.Toast;


public class CalenderView extends Activity {

public Calendar month;
public CalendarAdapter adapter;
public Handler handler;
public ArrayList&lt;String&gt; items; // container to store some random calendar items
private List&lt;String&gt; songArray;
public Long EXTRAS ;
private Long EXTRAS2;
private String EXTRASGIVE;


public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.calendar); //Set Calender View
    month = Calendar.getInstance(); //Gets current time and date
    onNewIntent(getIntent());

    //Get ID clicked from main screen
    Bundle extras = getIntent().getExtras();
    EXTRAS = extras.getLong("ID");


    //GET DATE INFORMATION FOR TASKS
    items = new ArrayList&lt;String&gt;(); //New Array List crea   ted
    adapter = new CalendarAdapter(this, month, EXTRAS); //

    GridView gridview = (GridView) findViewById(R.id.gridview); //Initliaase the gridview 
    gridview.setAdapter(adapter); //set the gridview to the days of the month

    handler = new Handler();
    handler.post(calendarUpdater);

    //Setting the title of the caledner
    TextView title  = (TextView) findViewById(R.id.title);
    title.setText(android.text.format.DateFormat.format("MMMM yyyy", month));

    //Set up the previous month BUTTON/TEXTVIEW
    TextView previous  = (TextView) findViewById(R.id.previous);
    previous.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            //if its january then go back a year
            if(month.get(Calendar.MONTH)== month.getActualMinimum(Calendar.MONTH)) {                
                month.set((month.get(Calendar.YEAR)-1),month.getActualMaximum(Calendar.MONTH),1);

                //else go back a month
            } else {
                month.set(Calendar.MONTH,month.get(Calendar.MONTH)-1);
            }
            refreshCalendar();
        }
    });





    //Set up next month BUTTON/TEXTVIEW
    TextView next  = (TextView) findViewById(R.id.next);
    next.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if(month.get(Calendar.MONTH)== month.getActualMaximum(Calendar.MONTH)) {                
                month.set((month.get(Calendar.YEAR)+1),month.getActualMinimum(Calendar.MONTH),1);
            } else {
                month.set(Calendar.MONTH,month.get(Calendar.MONTH)+1);
            }
            refreshCalendar(); //then refresh calender after changing month
        }
    });




    //Setting up when user clicks on the grid
            gridview.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id) {
            TextView date = (TextView)v.findViewById(R.id.date);
            if(date instanceof TextView &amp;&amp; !date.getText().equals("")) {



                String day = date.getText().toString(); 
                // DAY
                if(day.length()==1) {
                    day = "0"+day;                  
                }
                //MONTH
                int tempMonth = month.get(Calendar.MONTH);  
                //YEAR
                int tempYear = month.get(Calendar.YEAR);    //YEAR
                // DAY + MONTH + YEAR IN LOGCAT
                Log.d("DATECLICKED",tempYear+"-"+tempMonth+"-"+day); // LOG YEAR-MOTNH-DAY




                /////////// Opening dates for EACH task

                //OPEN 2ND DATABASE
                songArray =new ArrayList&lt;String&gt;();
                DatabaseRecords info2 = new DatabaseRecords(CalenderView.this);

                info2.open();

                //OUTPUT ALL DATES STORES IN DATABASE_RECORDS /////DOES THIS REALLY NEED TO BE HERE??!?!?!
                for(int i=0; i &lt; info2.getTaskName().size(); i++){
                    songArray = info2.getTaskName();
                    Log.d("Database_record", songArray.get(i)); 
                }



                //SEND ID OF TASK WHEN ADDING IN
                Intent intent = new Intent();
                Long ID = intent.getLongExtra("ID", EXTRAS);
                Log.d("INTENT EXTRA", ""+EXTRAS);
                //info2.getID(EXTRAS);


                String EXTRAS2 = ID.toString();





                info2.createEntry(EXTRAS2,tempYear+"-"+tempMonth+"-"+day);//put in info
                info2.close();//close database



            }       

        }

    });


}



public void refreshCalendar()
{
    TextView title  = (TextView) findViewById(R.id.title);

    adapter.refreshDays();
    adapter.notifyDataSetChanged();             
    handler.post(calendarUpdater); // generate some random calendar items               

    title.setText(android.text.format.DateFormat.format("MMMM yyyy", month));
}

public void onNewIntent(Intent intent) {
    //String date = intent.getStringExtra("date");
    //String[] dateArr = date.split("-"); // date format is yyyy-mm-dd
    //month.set(Integer.parseInt(dateArr[0]), Integer.parseInt(dateArr[1]), Integer.parseInt(dateArr[2]));

        Long ID = intent.getLongExtra("ID", 5);

        AlertDialog.Builder adb = new AlertDialog.Builder(
                CalenderView.this);
                adb.setTitle("ListView OnClick");

                adb.setMessage("Selected Item is = "
                + ID);
                adb.setPositiveButton("Ok", null);
                adb.show();       
}

public Long giveID(){


    return EXTRAS;

}

public Runnable calendarUpdater = new Runnable() {

    public void run() {
        items.clear();

        adapter.setItems(items);
        adapter.notifyDataSetChanged();
    }
};
</code></pre>

<p>}</p>
