Android : Getting String value from onClick method to onCreate above -
well might noob question since i'm new android wondering how string value inside onclick oncreate above.
it's edittext converted string
daa = txt.gettext().tostring(); i've used globally doesn't seem fetch value.
oncreate:
sp3 = (spinner) findviewbyid(r.id.hh); sp3.setonitemselectedlistener(new onitemselectedlistener() { calendar c1 = calendar.getinstance(); /*simpledateformat df = new simpledateformat("dd-mmm-yyyy"); string formatteddate = df.format(c1.gettime()); */ int hour = c1.get(calendar.hour_of_day); @override public void onitemselected(adapterview<?> parent, view v, int position, long id) { log.d("dp", ""+daa); edsp3.settext(pickup_hour[position]); string hourselected = pickup_hour[position]; if(integer.parseint(hourselected)<hour) { toast.maketext(onlinebooking.this, "choose greater hour", toast.length_long).show(); } } @override public void onnothingselected(adapterview<?> arg0) { } }); arrayadapter b3 = new arrayadapter(this, android.r.layout.simple_spinner_item, pickup_hour); b3.setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item); sp3.setadapter(b3); onclick:
@suppresslint("newapi") @override public void onclick(view v) { if (v == btncalendar) { // process current date final calendar c = calendar.getinstance(); myear = c.get(calendar.year); mmonth = c.get(calendar.month); mday = c.get(calendar.day_of_month); // launch date picker dialog datepickerdialog dpd = new datepickerdialog(this, new datepickerdialog.ondatesetlistener() { @override public void ondateset(datepicker view, int year, int monthofyear, int dayofmonth) { // display selected date in textbox if (year < myear) view.updatedate(myear,mmonth,mday); if (monthofyear < mmonth && year == myear) view.updatedate(myear,mmonth,mday); if (dayofmonth < mday && year == myear && monthofyear == mmonth) view.updatedate(myear,mmonth,mday); txtdate.settext(dayofmonth + "-" + (monthofyear + 1) + "-" + year); } }, myear, mmonth, mday); date newdate2 = c.gettime(); dpd.getdatepicker().setmindate(newdate2.gettime()); dpd.show(); daa = txtdate.gettext().tostring(); log.d("deepee", ""+daa); } } i'm trying string daa value inside onitemselected in oncreate
how can achieve this?
thanks in advance.
Comments
Post a Comment