i beginner android...when user scans qr code want replace content of expandablelistview scan result, doesn't seem work.
i displaying result qr scanner in layout works fine.
this code
format = (textview) view.findviewbyid(r.id.textview9); button = (button) view.findviewbyid(r.id.button); button.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { intent intent = new intent("com.journeyapps.barcodescanner.captureactivity"); intent.putextra("scan_mode", "product_mode"); startactivityforresult(intent, 1); } });
scan result listener:
public void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); if (requestcode == 1) { if (resultcode == activity.result_ok) { string contents = data.getstringextra("scan_result"); format.settext("" + contents); } else if (resultcode == activity.result_canceled) { toast toast = toast.maketext(getactivity(), "cancelled", toast.length_short); toast.show(); } } }
class devicelistadapter:
public class devicelistadapter extends baseexpandablelistadapter { arraylist<string> accesspoints; public devicelistadapter() { accesspoints = new arraylist<string>(); grouptitle.add("title"); } public void setaccesspoints(arraylist<string> rps, arraylist<string> mtype) { accesspoints = new arraylist<string>(rps); securitytype = new arraylist<string>(mtype); } @override public int getgroupcount() { return 1; } @override public int getchildrencount(int groupposition) { return accesspoints.size(); } @override public object getgroup(int groupposition) { return null; } @override public object getchild(int groupposition, int childposition) { return null; } @override public long getgroupid(int groupposition) { return 0; } @override public long getchildid(int groupposition, int childposition) { return 0; } @override public boolean hasstableids() { return false; } @override public view getgroupview(int gi, boolean isexpanded, view view, viewgroup parent) { layoutinflater inflater = (layoutinflater) getactivity().getsystemservice(context.layout_inflater_service); view = inflater.inflate(r.layout.p_item, null); textview textview = (textview) view.findviewbyid(r.id.name); textview.settext(grouptitle.get(a)); return view; } @override public boolean ischildselectable(int groupposition, int childposition) { return true; } @override public view getchildview(int a, int ci, boolean islastchild, view view, final viewgroup parent) { layoutinflater inflater = (layoutinflater) getactivity().getsystemservice(context.layout_inflater_service); view = inflater.inflate(r.layout.p_item, null); textview textview = (textview) view.findviewbyid(r.id.name); textview.settext(accesspoints.get(a)); textview.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { final dialog dialog = new dialog(getactivity()); dialog.requestwindowfeature(window.feature_no_title); window window = dialog.getwindow(); windowmanager.layoutparams wlp = window.getattributes(); } expandablelistview expandablelistview = (expandablelistview) parent; grouptitle.remove(0); expandablelistview.collapsegroup(0); dialog.dismiss(); }) return view; } }
Comments
Post a Comment