【问题标题】:Android zxing journeyapps bar code scanner inside fragmentAndroid zxing Journeyapps 条码扫描器内部片段
【发布时间】:2015-05-28 23:35:51
【问题描述】:

我正在使用journeyapps 进行条码扫描。

我的想法是有一个活动来膨胀包含标题的布局,并在该标题下方,一个片段。在该片段内部是我将使用条形码扫描仪午餐的地方,因此理想情况下扫描仪将在该片段内部进行扫描,并且标题始终可见。

在我的活动中,我有这个:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_with_header_and_fragment_placeholder);
}

@Override
protected void onResume() {
    super.onResume();

    Fragment fragment = new Fragment();

    FragmentManager fm = getFragmentManager();
    FragmentTransaction fragmentTransaction = fm.beginTransaction();
    fragmentTransaction.add(R.id.fragment, fragment);
    fragmentTransaction.commit();
}

在我的片段中,我有这个:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.dummy_view_with_blank_content, container, false);

    return rootView;
}


@Override
public void onResume() {
    super.onResume();
    IntentIntegrator.forFragment(this).setPrompt("Some prompt").initiateScan();
}

问题是当条码扫描器启动时,它会占用所有可用的屏幕。它没有加载到我的活动布局R.layout.activity_with_header_and_fragment_placeholder 中,因此我的标题是可见的。

有人知道我该如何解决这个问题吗?

【问题讨论】:

标签: android android-fragments zxing


【解决方案1】:

从项目页面读取,您可以提供custom layout 来修改加载应用程序本身的活动/片段的外观。尝试使用它

【讨论】:

  • 谢谢。我已经尝试过了,但问题是我的标题中有一个按钮,并且无法从我的活动中将侦听器附加到该按钮(使扫描仪午餐的那个)
  • 您可以访问该库的源代码..只需找到显示扫描仪活动/片段的类,使用您的按钮或菜单选项对其进行修改并将监听器放在那里,就足够了实现你的目标
猜你喜欢
  • 1970-01-01
  • 2013-05-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多