Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid drawable resource id conflict?
    primarykey
    data
    text
    <p>I've set up the /android project of ZXing 1.7 as a library referenced by my main android app project. As a quick test / proof of concept, I have used the CaptureActivity, in the same manner as described here: <a href="http://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcod" rel="nofollow">http://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcod</a>... </p> <p>Mostly, things work well, I can launch the CaptureActivity and receive the scanned data in my activity that launched it. However, I get some really strange behaviour, which I think may be related to resource IDs conflicting between my project and the /android ZXing project. This will take some explaining so please bear with me... </p> <p>I launch the CaptureActivity with this code:</p> <pre><code>Button scanBtn = (Button)findViewById(R.id.mainmenu_btn_scan); scanBtn.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { Intent i = new Intent("com.google.zxing.client.android.SCAN"); i.putExtra("SCAN_MODE", "QR_CODE_MODE"); startActivityForResult(i, SCAN_CODE); } }); </code></pre> <p><code>mainmenu_btn_scan</code> is defined in menu.xml:</p> <pre><code>&lt;LinearLayout android:id="@+id/mainmenu_view" style="@style/MainMenu" xmlns:android="http://schemas.android.com/apk/res/android"&gt; ... &lt;Button android:id="@+id/mainmenu_btn_scan" android:drawableTop="@drawable/btn_scan_drawable" style="@style/MainMenuButton" android:text="Scan"/&gt; ... &lt;/LinearLayout&gt; </code></pre> <p>btn_scan_drawable.xml is in /drawable, and is a drawable selector:</p> <pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:drawable="@drawable/scan_btn_pressed" android:state_focused="true" android:state_pressed="true" /&gt; ... &lt;/selector&gt; </code></pre> <p>The stange problem is this: when I hold the phone in a <em>lanscape</em> orientation and launch the CaptureActivity, I see the scan_btn_pressed image stretched across the display, and another copy of it also stretched across the "Place a barcode inside the viewfinder rectangle text...". This only occurs when I launch the activity while holding the phone in <em>landscape</em> orientation.</p> <p>I discovered that if I replace</p> <pre><code>android:drawableTop="@drawable/btn_scan_drawable" </code></pre> <p>with</p> <pre><code>android:drawableTop="@drawable/scan_btn_pressed" </code></pre> <p>The problem goes away and everything works perfectly, but I want to get it working with the selector (and understand why the problem occurs). How can a drawable from my activity's UI mysteriously show up in another activity? I'm new to Android development, but I've been googling and working at this issue all day and I can't seem to find out why this would be happening apart from some vague references to resource ID conflicts in the android docs.</p> <p>Note: I am using CaptureActivity as a rapid prototype / proof of concept only. I will implement my own activity leveraging the ZXIng library for the final app.</p>
    singulars
    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.
 

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