当一个月已经改变清除列表

当一个月已经改变清除列表

本文介绍了当一个月已经改变清除列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MainActivity ,必须有一个的TextView ,用于显示当前,和的ListView ,使用从的SQLite 加载数据。

In MainActivity, there has a textView, use to display current month, and a listView, use to load the data from SQLite.

WorkDetails

 btnSubmit.setOnClickListener(new View.OnClickListener() { // sumbit button is clicked
            public void onClick(View arg0) {
                first = objMyCustomBaseAdapter.getFistTime();
                String[] first1 = first.split(":", 2);
                last = objMyCustomBaseAdapter.getLastTime();
                String[] last1 = last.split(":", 2);
                a = ts.insertTimeSheet(name, weather, date2, status, first1[1], last1[1]);
                Intent intent = new Intent(getApplicationContext(), MainActivity.class);
                startActivity(intent);
            }
        });

当在WorkDetails的点击提交按钮,就会将数据插入的SQLite 和意图为 MainActivity

When the submit button in WorkDetails is clicked, it will insert data into SQLite and intent to MainActivity.

MainActivity

MainActivity 后,它将从 SQLite的检索的数据的ListView显示

    Calendar cal=Calendar.getInstance();
    SimpleDateFormat month_date = new SimpleDateFormat("MMMM");
    String month_name = month_date.format(cal.getTime());
    Month.setText(month_name); // get current month
    BuildList(); //


 public void BuildList()
    {
        sqlcon.open();
        Cursor cursor1=sqlcon.readData();

        String[] columns=new String[]{
        MyDatabaseHelper.Date,MyDatabaseHelper.TimeIn_Info,MyDatabaseHelper.TimeOut_Info
        };

        int[] to=new int[]
         {
           R.id.date,R.id.timeIn,R.id.timeOut
         };

        dataAdapter = new SimpleCursorAdapter(this, R.layout.retrieve_data,
                cursor1,
                columns,
                to,
                0);

        dataAdapter.setViewBinder(new ViewBinder());
        listView.setAdapter(dataAdapter);
    }

MainActivity的图片

我如何清除的ListView 月份时有什么改变?承担
  今天是 1月1日我在 MainActivity 31名单。当。。。的时候
  在WorkDetails保存按钮后, MainActivity 的ListView
   只显示一个列表(十二月列表项已经被清除)?

注意到ListView控件是明确的,但数据仍然存储在
  数据库。所以在SQLite的ID应该是32,不是1。

Noted that the listView is clear, but data still have to stored in database. So the ID in SQLite should be 32, not 1.

是否有可能实现这一目标?给我一些提示吧。

Is it possible to achieve this ? Give me some hints please.

推荐答案

您是从当地的DB(SQLite的)或MySQL数据库发送的JSON文件。在这种情况下,发送一个额外的价值,成功:真/假一起。你会读到的成功价值。如果这是真的,那么它已经被改变,否则不行。
除此之外,你的PHP脚本(MySQL数据库)或SQLite的将有机会获得日历/日期时间函数。你会调用该函数来检查它是否是一个新的月初。如果是,你将其他功能或发送数据的一部分,否则,你将发送数据的另一个片段。

You are sending as JSON file from your local db (sqLite) or mySQL db. In that case, send a extra value, success: true/false along. You will read the success value. If it is true, then it has been changed or else not.Beside, your php script (mySQL db) or sqLite will have access to calender / date time function. You will call that function to check if it is the beginning of a new month. If it is, you will another function or send a portion of data or ELSE, you will send another fragments of data.

这篇关于当一个月已经改变清除列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 03:41