Android中的约会问题

时间:2013-03-26 11:44:15

标签: android appointment

我创建了一个保险应用程序,我从客户端获得约会日期。我必须查看特定日期(今天,明天),一周(从今天起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>

0 个答案:

没有答案