I m new to Android.I had many items in listview. I want to compare the date in list item with the current date and to deactivate the list items whose date has expired. I tried many things but could not find right answer.
The code which I tried is
public class TestApp extends Activity 
             {
           Activity context;
            ListView lv = null;
            protected void onCreate(Bundle savedInstanceState) 
              {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.testlist);
      lv = (ListView) findViewById(R.id.testAppList);
    Log.v("finished dateslist", "true");
    String dateFormat="dd-MMM-yyyy";
    DateFormat formatter = null;
    Calendar calendar = null;
    formatter = new SimpleDateFormat(dateFormat);
    // Date date = new Date(0);
    long date = System.currentTimeMillis();  
    final String current_date = formatter.format(date);
    //Calendar cal = Calendar.getInstance();
    //String current_date = dateFormat.format(cal.getTime());
    Log.d("Current date", current_date);
    lv.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1,
                int position, long arg3) {
            int i;
            /*arg1.setEnabled(false);
            if(!arg1.isEnabled())
            {
                lv.setSelector(android.R.color.transparent); 
                lv.setActivated(false);
            }*/
               for(i=0;i<Constants.test_endDate.size();i++)
                 {
                    if((current_date.compareTo(Constants.test_endDate.get(i)))>0)
                    {
                        Constants.selected_test_id = Integer.parseInt(Constants.test_ID.get(position));
                        Constants.selected_testName = Constants.test_name.get(position);
                        Constants.selected_test_total_questions = Constants.test_totalQuestions.get(position);
                        Constants.selected_testTimeleft = Constants.test_duration.get(position);
                        Constants.selected_testcmid = Constants.test_cmid.get(position);
                        displayInstructionsPage();
                    break;
                    }
            else
            {
                    arg1.setClickable(true);
                    arg1.setFocusable(true);
                    arg1.setEnabled(false);
                    Toast.makeText(getApplicationContext(), "Date Expired", Toast.LENGTH_SHORT).show();
                    if(!arg1.isEnabled())
                    {
                        lv.setSelector(android.R.color.transparent); 
                        lv.setActivated(false);
                    }
                    break;
                }                       
            }                           
        }           
    }); 
please help to sort out the problem.
 
     
     
    