button - How to pass data from function to external object (android) -
im using impimentation of zyxel barcode scanner , want pass string 'upc' edittext object out of function, how can this?
protected void onactivityresult(int requestcode, int resultcode, intent data) { switch(requestcode) { case intentintegrator.request_code: { if (resultcode != result_canceled) { intentresult scanresult = intentintegrator.parseactivityresult(requestcode, resultcode, data); if (scanresult != null) { string upc = scanresult.getcontents(); } } break; } } } second question:
i want call function after clicking button this:
button3.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { intentintegrator.initiatescan(this); } }); but error:
"the method initiatescan(activity) in type intentintegrator not applicable arguments (new view.onclicklistener(){})"
so ive tried solve problem calling function when clicking button funtction call original function
it's this:
button3.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { turntheshiton(); } }); public void turntheshiton() { intentintegrator.initiatescan(this); } but it's not real elegant way solve out, there other way?
thanks!!
string upc = scanresult.getcontents(); updateeditfield(upc );// or use <activity-name>.this.updateeditfield(upc ); private void updateeditfield(string str){ editfield ef = (editfield)findviewbyid(r.id.<ef_id>); if(null!=ef){ ef.settext(str): } } second question:
in intentintegrator.initiatescan(this); use <activity-name>.this activity.this
Comments
Post a Comment