1

我创建了一个保险应用程序,我从客户那里获得了约会日期。我必须查看特定日期(今天、明天)、周(从今天起 7 天)、月份(从今天起 30 天)和六个月、一年的约会。

创建了一个自定义适配器来显示详细信息。它适用于今天和明天,但没有显示周、月、年。请帮我。

<html>
private void today() {
        detail.setText("Today");

        // Convert the Current Date to SimpleDateFormat

        SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
        tdate = c.getTime();
        sdate = sdf.format(tdate);

        String sel = "select * from addclient where AppointDate='" + sdate
                + "'order by AppointTime";
        cur = db.rawQuery(sel, null);
        cur.moveToFirst();

         value();   
    }



private void week() {

        detail.setText("Week");

        // Convert the FromDate and ToDate to SimpleDateFormat

        SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
        fdate = c.getTime();
        fromdate = sdf.format(fdate);

        // 7 days to add
        c.add(Calendar.DATE, 7);
        tdate = c.getTime();
        todate = sdf.format(tdate);

        // Checking Datebase Table

        String sel = "SELECT * FROM addclient WHERE AppointDate BETWEEN '"
                + fromdate + "' AND '" + todate + "' order by AppointDate";

        cur = db.rawQuery(sel, null);
        cur.moveToFirst();

        value();
    }



private void month() {

        detail.setText("Month");

        // Convert the FromDate and ToDate for Month to SimpleDateFormat

        SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
        fdate = c.getTime();
        fromdate = sdf.format(fdate);

        // 1 Month to add
        c.add(Calendar.MONTH, 1);
        tdate = c.getTime();
        todate = sdf.format(tdate);

        // Checking Datebase Table
        String sel = "SELECT * FROM addclient WHERE AppointDate BETWEEN '"
                + fromdate + "' AND '" + todate + "' order by AppointDate";
        cur = db.rawQuery(sel, null);
        cur.moveToFirst();

         value();
    }



private void year() {

        detail.setText("Year");


        SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
        fdate = c.getTime();
        fromdate = sdf.format(fdate);

        // 1 Year to add
        c.add(Calendar.YEAR, 1);
        tdate = c.getTime();
        todate = sdf.format(tdate);

        // Checking Datebase Table
        String sel = "SELECT * FROM addclient WHERE AppointDate BETWEEN '"
                + fromdate + "' AND '" + todate + "' order by AppointDate";
        cur = db.rawQuery(sel, null);
        cur.moveToFirst();

         value();
}

public void value(){

        while (!cur.isAfterLast()) {
            count++;
            cur.moveToNext();
        }

        cur.moveToFirst();

        // Assigning count as the array length
        name = new String[count];
        address = new String[count];
        date = new String[count];
        time = new String[count];

        int i = 0;

        // Retrieve the database values 
        while (!cur.isAfterLast()) {
            String s1 = cur.getString(0).toString();
            String s2 = cur.getString(3).toString();
            String s3 = cur.getString(16).toString();
            String s4 = cur.getString(17).toString();

            name[i] = s1;
            address[i] = s2;
            date[i] = s3;
            time[i] = s4;
            i++;

            cur.moveToNext();
        }

        lv.setAdapter(new MyCustomAdapter(name, address, date, time));
}
</html>
4

0 回答 0