我找不出如何在我的Activity中使用EditText來搜索日期範圍的sqlite。我想我需要以某種方式製作editText1和2字符串,但我不知道如何在數據庫中執行此操作。使用EditText從SQLite中的兩個日期獲取數據
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 - 8 - 16' 這些靜態值與「2013 - 8 - 21這個完美的作品。我在我的arrayList中完美地顯示出它只是來自sqlite的靜態日期。
在我的活動,我有兩個EDITTEXT ...
EditText editText1,editText2;
edittext1 =(EditText)findViewById(R.id.editText1);
edittext2 =(EditText)findViewById(R.id.editText2);
,我有一個onClick的按鈕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);
}});
在點擊鏈接就可以得到Editext 的價值'字符串值1 = edittext1.getText()。toString(); 字符串VALUE2 = edittext2.getText()。的toString()' 然後值傳遞給該方法 'getAllsaleweekly(值1,值2)' – Raghunandan
應該完全是一個答案...謝謝。如果我被允許,你發佈的答案我會給你點。 – SmulianJulian
我確實發佈了它作爲答案,很高興我能幫上忙 – Raghunandan