Note that there are some explanatory texts on larger screens.

plurals
  1. POReading a barcode with zxingjar-1-1.jar
    primarykey
    data
    text
    <p>I am reading a barcode using zxingjar-1-1.jar and it works fine. But now, I would like to put a QUIT button in the layout where the capture is made but I don't know how to identify the button in the activity code. Any ideas about how to solve it? </p> <p>This is my MainActivity.java:</p> <pre><code> 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 the last parameter to true to open front light 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: } } } </code></pre> <p>And I have 2 layouts: main.xml and capture_new.xml</p> <p>MAIN.XML:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;Button android:id="@+id/scan_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/scan" /&gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/scan_resut_lable" android:textColor="#fff" /&gt; &lt;TextView android:id="@+id/scan_result" android:layout_width="fill_parent" android:layout_height="wrap_content" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>CAPTURE_NEW.XML</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;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" /&gt; &lt;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" /&gt; &lt;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" /&gt; &lt;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" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Is it possible to use "buttonVolverScan" (inside capture_new.xml) with an eventlistener like this inside the MainActivity.java (where the layout is main.xml)??:</p> <pre><code>botonVolver.setOnClickListener(new Button.OnClickListener() { public void onClick(View view) { finish(); } }); </code></pre> <p>Thanks for your help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload