如何标签主机zxing QR code扫描仪集成? [英] How to integrate tab host with zxing qr code scanner?

查看:261
本文介绍了如何标签主机zxing QR code扫描仪集成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要zxing QR code扫描器,其中是有我的应用程序三个选项卡我的应用程序集成。

I want to integrate zxing qr code scanner in my application which is having three tabs in my application.

目前,当我的标签栏按钮操的人得到当时pssed我打电话zxing QR code的scann活动$ P $但是当过它的调用它显示象下面这样的错误。

Currently when my one of the tab bar butto gets pressed at that time I am calling zxing qr code's scann activity but when ever its calling it is showing error like below.

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.beepz/com.google.zxing.client.android.CaptureActivity}: java.lang.RuntimeException: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'

而我的code是有两个选项卡主机控制和我在电话的活动实例标签主机,如下图所示。

Rather my code is having both tab host control and I have instantiated tab host in my activity call as shown below.

XML文件(Capture.xml):

XML File (Capture.xml) :

<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android1="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<FrameLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <SurfaceView
        android:id="@+id/preview_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_centerInParent="true" >

        <TabHost
            android:id="@android:id/tabhost"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >

                <TabWidget
                    android:id="@android:id/tabs"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" >
                </TabWidget>

                <FrameLayout
                    android:id="@android:id/tabcontent"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >

                    <LinearLayout
                        android:id="@+id/tab1"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" >
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/tab2"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" >
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/tab3"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" >
                    </LinearLayout>
                </FrameLayout>
            </LinearLayout>
        </TabHost>

      <com.google.zxing.client.android.ViewfinderView
            android:id="@+id/viewfinder_view"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@color/transparent" />

    </SurfaceView>
</FrameLayout>

Java文件:(CaptureActivity.java)

Java File : (CaptureActivity.java)

public final class CaptureActivity extends TabActivity implements
    SurfaceHolder.Callback {

private TabHost tabHost;

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    window.setFormat(PixelFormat.TRANSLUCENT);

    setContentView(R.layout.capture);

    tabHost = getTabHost();
    Intent intent = new Intent().setClass(this, first.class);      
    TabSpec spec = tabHost.newTabSpec("First Tab").setIndicator("First Tab",getResources().getDrawable(R.drawable.iconinfo)).setContent(intent); 
    tabHost.addTab(spec);
    .
    .
    .

}

我是否需要更改清单文件或其他任何东西,我需要做的事情吗?

Do I need to change any thing in manifest file or anything else I need to do?

任何机构可以帮我我该怎么办?

Can any body please help me what should I do?

在此先感谢...

推荐答案

最后我解决我自己我的问题,问题是,有在我的主要项目CaptureActivity.java文件。并通过在主项目的CaptureActivity.java文件中添加TabHost解决的问题。

At last I solved my problem on my own, the problem was, there was a CaptureActivity.java file in my main project. And problem solved by adding TabHost in the main project's CaptureActivity.java file.

希望这将有助于其他人了。

Hopefully It will be helpful to others too.

这篇关于如何标签主机zxing QR code扫描仪集成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆