我不知道如何在我的活动中使用 EditText 来搜索 sqlite 的日期范围。我想我需要以某种方式制作 editText1 和 2 个字符串,但我不知道如何在我的数据库中做到这一点。
在sqlite中
public ArrayList<HashMap<String, String>> getAllsaleweekly() {
ArrayList<HashMap<String, String>> wordList;
GregorianCalendar gc = new GregorianCalendar();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MMM-dd");
String today = sdf.format(gc.getTime());
wordList = new ArrayList<HashMap<String, String>>();
String selectQuery = "SELECT * FROM INSERTS WHERE saleDate BETWEEN '2012-Aug-16' AND '2013-Aug-21'";
这很完美,除了我不想要 2012-Aug-16' 和 '2013-Aug-21 的静态值。我完美地显示在我的 arrayList 中,它只是来自 sqlite 的静态日期。
在我的活动中,我有两个editText ...
EditText editText1,editText2;
edittext1 =(EditText)findViewById(R.id.editText1);
edittext2 =(EditText)findViewById(R.id.editText2);
我有一个 onClick for Button bydate
bydate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
ArrayList<HashMap<String, String>> saleList = controller.getAllsaleweekly();
ListAdapter adapter = new SimpleAdapter(whatever.this,whateverList, R.layout.whatever, new String[] {"whatever","whatever", "whatever", "whatever","whatever","whatever", "whatever"}, new int[] { R.id.whatever, R.id.whatever, R.id.whatever, R.id.whatever,R.id.whatever, R.id.v, R.id.whatever});
setListAdapter(adapter);
}});