android - Reading a barcode with zxingjar-1-1.jar -
i reading barcode using zxingjar-1-1.jar , works fine. now, set quit button in layout capture made don't know how identify button in activity code. ideas how solve it?
this mainactivity.java:
public class mainactivity extends activity { private handler handler = new handler(); private textview txtscanresult; private imageview botonvolver; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); txtscanresult = (textview) findviewbyid(r.id.scan_result); view btnscan = findviewbyid(r.id.scan_button); botonvolver = (imageview) findviewbyid(r.id.buttonvolverscan); // scan button btnscan.setonclicklistener(new onclicklistener() { public void onclick(view v) { // set lastly parameter true open front end lite if available intentintegrator.initiatescan(mainactivity.this, r.layout.capture_new, r.id.viewfinder_view, r.id.preview_view, true); } }); } @override protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); switch (requestcode) { case intentintegrator.request_code: intentresult scanresult = intentintegrator.parseactivityresult(requestcode, resultcode, data); if (scanresult == null) { return; } final string result = scanresult.getcontents(); if (result != null) { handler.post(new runnable() { public void run() { txtscanresult.settext(result); } }); } break; default: } } } and have 2 layouts: main.xml , capture_new.xml
main.xml:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <button android:id="@+id/scan_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/scan" /> <textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/scan_resut_lable" android:textcolor="#fff" /> <textview android:id="@+id/scan_result" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </linearlayout> capture_new.xml
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <surfaceview android:id="@+id/preview_view" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerinparent="true" android:background="@drawable/fondo_scan4" /> <jim.h.common.android.zxinglib.view.viewfinderview android:id="@+id/viewfinder_view" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignparentright="true" android:background="#00000000" /> <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centervertical="true" android:layout_alignparentright="true" android:layout_marginright="20dip" android:src="@drawable/logo_scan" /> <imageview android:id="@+id/buttonvolverscan" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centervertical="true" android:layout_alignparentleft="true" android:layout_marginleft="20dip" android:src="@drawable/boton_scan" /> </relativelayout> is possible utilize "buttonvolverscan" (inside capture_new.xml) eventlistener within mainactivity.java (where layout main.xml)??:
botonvolver.setonclicklistener(new button.onclicklistener() { public void onclick(view view) { finish(); } }); thanks help.
android layout android-activity barcode zxing
No comments:
Post a Comment