text - How do I set up a listener? -
i think need listener, can’t set up. in code below, both time dialog , date dialog work. little dialog w/ rollers comes up, select date/time, select , have date. cannot text input work. have tried several iterations of code sample program had: bnbodyentered = true; bodydialog = new textinputdialog(this); bodydialog.settext("body"); code showed text dialog w/ alphabet roller, program ran past , when entered few letters , selected nothing happened. makes since did not set listener. added (as noted) bodydialog.setondismisslistener(textsetlistener); using several "seton----listener" values , either still runs past, or various compile errors.
this wimmone watch, version 7 , no virtual keyboard. needs dialog.
(note: deleted gobs of commented code before posting - possibly more, if doesn't make since - sorry. )
thanks, clark
/****************************** * wimm imports ******************************/ import com.wimm.framework.app.dialog; import com.wimm.framework.app.datepickerdialog; import com.wimm.framework.app.datepickerdialog.ondateselectedlistener; import com.wimm.framework.app.launcheractivity; import com.wimm.framework.app.textinputdialog; import com.wimm.framework.app.timepickerdialog; import com.wimm.framework.app.timepickerdialog.ontimeselectedlistener; @ override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); log.d("remindea","01s oncrt"); setcontentview(r.layout.reminder_edit_activity); . . . . . . mbodytext = (edittext)findviewbyid(r.id.body); mtimebutton = (button)findviewbyid(r.id.reminder_time); mdatebutton = (button)findviewbyid(r.id.reminder_date); mconfirmbutton = (button)findviewbyid(r.id.confirm); log.d("remindea","10s oncrtv df"); //------------- text input mbodytext.setonclicklistener( new view.onclicklistener() { public void onclick(view v) { log.d("remindea","21> onclkv:body"); showdialog(body_dialog_id); log.d("remindea","22< onclkv:body:" + strbody); mbodytext.settext(bodydialog.gettext()); return; } } ); //-------------------------- time input mtimebutton.setonclicklistener( new view.onclicklistener() { @override public void onclick(view v) { log.d("remindea","25> onclkv:time"); showdialog(time_dialog_id); log.d("remindea","26< onclkv:time"); } } ); //-------------------------- date input mdatebutton.setonclicklistener( new view.onclicklistener() { @override public void onclick(view v) { log.d("remindea","30> onclkv:time"); showdialog(date_dialog_id); log.d("remindea","31< onclkv:time"); } } ); protected dialog oncreatedialog(int id) { log.d("remindea","70s dialog:" + id); switch (id) { // if want time dialog-------------- case time_dialog_id: log.d("remindea","71s time_dialog_id"); timedialog = new timepickerdialog(this); timedialog.settimeselectedlistener(timesetlistener); timedialog.settime(mcalendar.get(calendar.hour_of_day), mcalendar.get(calendar.minute)); log.d("remindea","73s time_d:" + timedialog); return timedialog; // if want date dialog --------------- case date_dialog_id: log.d("remindea","75s date_dialog_id-26"); mcalendar = calendar.getinstance(); log.d("remindea","76s date_dialog_id-27"); datedialog = new datepickerdialog(this); datedialog.setdateselectedlistener(datesetlistener); datedialog.setdate(mcalendar.get(calendar.day_of_month), mcalendar.get(calendar.month )); log.d("remindea","77s date_d:" + datedialog); return datedialog; // if want text input dialog --------------------- case body_dialog_id: log.d("remindea","80s body_dialog_id"); bnbodyentered = true; log.d("remindea","81s title"); bodydialog = new textinputdialog(this); //---> added line below create listener: error <----- // error below: setondismisslistener cannot resolved type bodydialog.setondismisslistener(textsetlistener); //------------------------------------------ //also //.setonkeylistener(onkeylistener) - others log.d("remindea","82s new"); bodydialog.settext("body"); log.d("remindea","83x:" + bodydialog); return bodydialog; } return null; } private ontimeselectedlistener timesetlistener = new ontimeselectedlistener() { public void ontimeselected(int arg0, int arg1) { log.d("remindea","90s ontimeselected"); inthh = arg0; intmn = arg1; log.d("remindea","91s schedule:" + inthh + ":" + intmn); //updatedisplay(); } }; private ondateselectedlistener datesetlistener = new ondateselectedlistener() { public void ondateselected(int arg0, int arg1) { log.d("remindea","92s ontimeselected"); intdd = arg0; intmm = arg1; log.d("remindea","93s schedule:" + intdd + ":" + intmm); //updatedisplay(); } }; //------------------------------------ // -----> error: setondismisslistener cannot resolved type private setondismisslistener textsetlistener = new setondismisslistener //------------------------------------ { private void textsetlistener() // bodysetlistener () { log.d("remindea","100s bodylisner"); //<- not here on <done> return; } };
after many hours of guess , error, worked.
i don't think "return bodydialog" anything; ended updating edittext field directly listener. "arg0" has long name of dialog - nothing usefull. have have prevent compile errors.
this unique wimmone there no virtual keyboard , need use text input dialog.
protected dialog oncreatedialog(int id) { switch (id) . . . . case body_dialog_id: bodydialog = new textinputdialog(this); bodydialog.setondismisslistener(textsetlistener); return bodydialog; private ondismisslistener textsetlistener = new ondismisslistener() { @override public void ondismiss(dialoginterface arg0) { log.d("remindea","101s bodylisner" + arg0); string strxx = bodydialog.gettext(); mbodytext.settext(strxx); } };
Comments
Post a Comment