datepicker - how to display two different date picker in android -


hi in below displaying 2 date picker 1 fromdate , date.but took 2 different methods calling.but using single function how display 2 different date picker selected date

can 1 me

expected output:

for example fromdate:2015-04-01 todate:2015-04-23  

java

public class general_report extends activity implements onclicklistener{       edittext fromdate,todate;     datepickerdialog fromdatepickerdialog;     datepickerdialog todatepickerdialog;     simpledateformat dateformatter;     button report;      public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.general_report);         report=(button)findviewbyid(r.id.report);          report.setonclicklistener(new onclicklistener() {              @override             public void onclick(view v) {                  string selectedfromdate=fromdate.gettext().tostring();                 string selectedtodate=todate.gettext().tostring();                  intent = new intent(getapplicationcontext(),general_patient_list.class);                 i.putextra("date1", selectedfromdate);                 i.putextra("date2", selectedtodate);                 startactivity(i);              }         });         dateformatter = new simpledateformat("yyyy-mm-dd", locale.us);          findviewsbyid();         findviewsbyid1();          setdatetimefield();         setdatetimefield1();       }        private void findviewsbyid() {         fromdate = (edittext) findviewbyid(r.id.etxt_fromdate);         fromdate.setinputtype(inputtype.type_null);         fromdate.requestfocus();      }     private void findviewsbyid1() {         todate = (edittext) findviewbyid(r.id.etxt_todate);         todate.setinputtype(inputtype.type_null);         todate.requestfocus();      }      private void setdatetimefield() {         fromdate.setonclicklistener(this);           calendar newcalendar = calendar.getinstance();         fromdatepickerdialog = new datepickerdialog(this,                 new ondatesetlistener() {              public void ondateset(datepicker view, int year,                     int monthofyear, int dayofmonth) {                 calendar newdate = calendar.getinstance();                 newdate.set(year, monthofyear, dayofmonth);                 fromdate.settext(dateformatter.format(newdate                         .gettime()));              }          },          newcalendar.get(calendar.year),         newcalendar.get(calendar.month),         newcalendar.get(calendar.day_of_month));      }     private void setdatetimefield1() {         todate.setonclicklistener(this);           calendar newcalendar = calendar.getinstance();         todatepickerdialog = new datepickerdialog(this,                 new ondatesetlistener() {              public void ondateset(datepicker view, int year,                     int monthofyear, int dayofmonth) {                 calendar newdate = calendar.getinstance();                 newdate.set(year, monthofyear, dayofmonth);                 todate.settext(dateformatter.format(newdate                         .gettime()));              }          },          newcalendar.get(calendar.year),         newcalendar.get(calendar.month),         newcalendar.get(calendar.day_of_month));      }      public void onnothingselected(adapterview<?> arg0) {      }     @override     public void onclick(view view) {         if (view == fromdate) {             fromdatepickerdialog.show();         }         if (view == todate) {             todatepickerdialog.show();         }      } 

set 2 different date picker in 2 different button..for example if press todate show date picker popup , when press fromdate show date picker..


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -