本文介绍了Android系统。为什么会在活动1的图像最终在活动2? (Zxing CaptureActivity为活动2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有进展顺利开发新的应用程序,直到我开始打扮的接口。

All was going well developing a new app until I started dressing up the interface.

我已经实现斑马线条code扫描我的项目,为用户方便,我自定义的控制范围之内。

I have implemented the zxing barcode scanner within my project for user convenience and my custom control.

我做的CaptureActivity唯一的变化是在处理扫描结果。我还通过AndroidManifest.xml中开枪抢走了意图过滤器,以避免被提供的请求吧code扫描应用程序句柄我的应用程序。 (这感觉不对具有Android操作系统提供我的活动Xzing酒吧code扫描仪的辛苦赚来的迷死人的旁边)

The only changes I make to the CaptureActivity are in handling the scan results. I also shot through the AndroidManifest.xml and took away the intent filters to avoid my app from being offered for the requests the barcode scanner app handles. (It doesn't feel right having the android OS offer my activity alongside of the hard earned "awesomeness" of Xzing's Barcode Scanner)

我添加了两个ImageViews到我的索引活动,其中1触发扫描仪。有趣的是,在扫描仪中显示的图像不链接到​​扫描仪1。

I added two ImageViews to my index activity and 1 of them triggers the scanner. The interesting part is that the image that shows up in the scanner is not the 1 that links to the scanner.

综上所述,2图像导航,第二次图像会导致扫描仪,第一个图像阻止我的扫描仪视图。

In summary, 2 images for navigation, Second Image leads to scanner, first image is blocking my scanner view.

起初我更名的资产(被add_card.png到add_tag​​.png),我有扫描仪的清洁看法,但此后的形象已经在悄悄回来了。

At first I changed the name of the asset (was add_card.png to add_tag.png) and I had a clean view of the scanner, but since then the image has crept back in.

下面是一些索引活动code

Here is some index activity code

//in on create
ImageView view = (ImageView) findViewById(R.id.addTagButton);
        view.setOnClickListener(addCardListener);

view = (ImageView) findViewById(R.id.scanButton);
        view.setOnClickListener(scanListener);

// end of in on create

private OnClickListener addCardListener = new OnClickListener() {
    public void onClick(View v) {
        startActivity(new Intent(getApplicationContext(), AddCard.class));
    }
};
private OnClickListener scanListener = new OnClickListener() {
    public void onClick(View v) {
        startActivity(new Intent(getApplicationContext(), CaptureActivity.class));
    }
};

一些XML,索引文件加载

Some xml that the index file loads

<ImageView  android:src="@drawable/add_tag"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="6dip"
        android:layout_marginLeft="12dip"
        android:id="@+id/addTagButton"
        android:layout_gravity="bottom|left"
></ImageView>

我只能在CaptureActivity做出的更改是在读的是吧code后,引发了code。

And the only changes I made in the CaptureActivity are in the code that is triggered after reading the barcode.

更新

我尝试设置启动器CaptureActivity,图像没有显示想在画面了。这是从爬完意见,我认为我们都希望这个问题会被复制,这样我就开始寻找在1的地方,我已经越过了我的名单。 (这就是我发现我的钥匙时,他们丢失)

I tried setting the launcher to CaptureActivity and the image is not showing up like in the screenshot. This was advice from Pawan and I think we were both hoping the problem would be replicated so that I would start looking in the 1 place I had already crossed off my list. (That is how I find my keys when they are lost)

更新2

我试图改变的问题(add_tag​​)的ImageView的一个按钮---没有变化
如果我从XML,不适用的解决方案中删除ImageView的问题,这个问题就会消失。
这是一些关于当PNG已经加载到内存中。我装比我的指数活动的上述多个图像,但图像add_tag​​一再表明了在相机。然后,如果我保持资源图片资源/绘制,但从未将其加载到指数的活动,那么它不显示在相机。

I tried changing the ImageView in question (add_tag) to a button --- no changeIf I remove the ImageView in question from xml, not an applicable solution, the issue disappears.It is something about when that png is already loaded into memory. I have more images loaded than described above in my Index activity, but the add_tag image consistently shows up over the camera. Then if I keep the image resource in res/drawable, but never load it into the Index activity, then it doesn't show up over the camera.

有哪些原因从活动1将活性2最终的图像?
我如何收拾索引活动,使这是因为如果在XML中从来没有装的onStop的形象?

What are some reasons an image from the activity1 will end up in activity2?How can I clean up Index activity so that it is as if the xml never loaded the image in onStop?

更新3
我再也不会遇到问题,可以继续前进。我如果它与相机一般或Zxing做仍然不确定。
考虑到肖恩的它具有Java.R做咨询,我试图去除是造成问题,重命名,插入到项目中的绘制。这并没有完全工作。结果
它解决了,当我加了我绘制的副本到项目中。结果
可绘制的文件夹现在开始用
add_card
add_tag
...等

UPDATE 3I do not experience the problem anymore and can move on. I am still unsure if it has to do with the camera in general or Zxing.Considering Sean's advice about it having to do with Java.R, I tried removing the drawable that was causing the problem, rename, insert into project. This didn't exactly work.
It resolved when I added a copy of my drawable into the project.
The drawable folder now starts withadd_cardadd_tag...etc

如果我把我的ImageView在指数活动add_card,出现问题,如果我把我的ImageView为add_tag​​不会发生问题。
- >这使我相信,第一个(按字母顺序)绘制资源将扫描程序冲突
我要保持一个占位符图像,我从来没有加载的绘制文件夹的上方,并保持我的手指穿过。

If I set my ImageView to add_card in the Index activity, the problem occurs, If I set my ImageView to add_tag no problem occurs.--> This leads me to believe that the first (alphabetically) drawable resource will conflict with ScannerI am going to keep a placeholder image that I never load as the top of the drawable folder and keep my fingers crossed.

有一些耐人寻味。 (我仍然开放给别人向我解释为什么发生这种情况)

There's some food for thought. (I am still open to someone explaining to me why this is happening)

PS随意,如果你觉得我的旅程,解决的办法是有点臃肿编辑了我的问题。

PS Feel free to edit down my question if you feel my journey to the solution is a little bloated.

推荐答案

最有可能的解释是,您生成的 R.java 文件是不同步的编译$ C $℃。

The most likely explanation is that your generated R.java file is out of sync with your compiled code.

这可能是因为你的字节code指的是改变了,现在这么在错误的图像指向常量值。只是干净,重新编译,如果是这样。但我不认为这是它。

It's possible that your bytecode refers to constant values that have since changed, and so are now pointing at the wrong images. Just clean and recompile, if so. But I don't think that's it.

我认为你已经从我们的code资源ID,和你的,并且它不使用你觉得之一。这是有症状的复制和粘贴我们的项目。我们强烈建议您不要从克隆开始;有太多太多的那些已经的。这将是更好的(也可能是不易出错)写自己的扫描应用程序,并根据需要重用的点点滴滴。

I think you've got resource IDs from our code, and yours, and it's not using the one you think. This is symptomatic of copying-and-pasting our project. We strongly discourage starting from a clone; there are far too many of those already. It would be better (and probably less error prone) to write your own scanner app and reuse bits and pieces as needed.

这篇关于Android系统。为什么会在活动1的图像最终在活动2? (Zxing CaptureActivity为活动2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 03:37