ZXING Android嵌入式IntentIntegrator的用法 [英] ZXING Android Embedded Usage of IntentIntegrator
问题描述
我是Android开发的新手,仍然试图掌握一些概念。我发现最好的学习方法是通过项目直接进入深层。话虽如此,这是我的问题:
I am new to Android development and still trying to get the grasp of some of the concepts. I find the best way to learn is to jump right into the deep end with a project. With that said, here is my question:
我已将ZXing Android Embedded集成到我的应用程序中;但是,我无法理解您使用IntentIntegrator的方式。我正在尝试做的就是当用户点击按钮时将QR扫描仪调到屏幕上。我一直试图按照他们的github链接[这里] [1]上的说明但是没有成功。
I have integrated ZXing Android Embedded into my application; however, I am having trouble understanding the way in which you use IntentIntegrator. All I am trying to do at the moment is call the QR scanner to the screen when the user taps a button. I have been trying to follow the instructions on their github link [here][1] but have been unsuccessful.
这是我的功能到目前为止的样子:
Here is what my function looks like so far:
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
IntentIntegrator integrator = new IntentIntegrator(this);
IntentIntegrator.forFragment(this).initiateScan();
}
});
我一直收到错误消息:
错误:(109,25)错误:类
中的构造函数IntentIntegrator IntentIntegrator不能应用于给定类型; required:Activity
found:意图原因:实际参数Intent无法通过方法调用转换转换为
活动
Error:(109, 25) error: constructor IntentIntegrator in class IntentIntegrator cannot be applied to given types; required: Activity found: Intent reason: actual argument Intent cannot be converted to Activity by method invocation conversion
此外,当我将鼠标放在Android Studio中的'(this)'时,它说:
Also, as I put my mouse over '(this)' in Android Studio, it says:
anonymous android.view.View。 onClickListener
anonymous android.view.View.onClickListener
非常感谢任何帮助,谢谢!如果您需要任何其他信息,请告诉我。
Any help would be greatly appreciated, thanks! If you need any other information, please let me know.
推荐答案
以下可以工作:
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new IntentIntegrator(getActivity()).initiateScan();
popupWindow.dismiss();
}
});
这篇关于ZXING Android嵌入式IntentIntegrator的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!