2017-04-20 3 views
0

, Zxing 스캐너 카메라 뷰에 버튼을 추가하는 방법나는 텍스트 뷰와 그것의 버튼의 몇 가지를 추가 할 <a href="https://i.stack.imgur.com/iogXO.jpg" rel="nofollow noreferrer">enter image description here</a></p> <p>, 난 많은 방법을 시도했지만 아무것도 할 수있는 사람을 일하지 내 현재 Zxing 스캐너 화면은 다음과 같습니다

private ZXingScannerView mScannerView; 
    @Override 
    public void onCreate(Bundle state) { 
     super.onCreate(state); 
     setContentView(R.layout.activity_qrresult); 
     mScannerView = new ZXingScannerView(this); 
     setContentView(mScannerView);    


    } 

    @Override 
    public void onResume() { 
     super.onResume(); 
     mScannerView.setResultHandler(this); 
     mScannerView.startCamera();   
     Toast.makeText(getApplicationContext(),"Scan QR code to Send 
    Money",Toast.LENGTH_LONG).show(); 
    } 

    @Override 
    public void onPause() { 
     super.onPause(); 
     mScannerView.stopCamera();   // Stop camera on pause 
    } 

    @Override 
    public void handleResult(Result rawResult) { 
     // Do something with the result here 
     if(rawResult.getText().toString().equals("Test Ewallet Test")){ 
      Toast.makeText(getApplicationContext(), rawResult.getText(), 
    Toast.LENGTH_SHORT).show(); 
      Intent go = new Intent(qrresult.this,sendmoney.class); 
      startActivity(go); 

     }else { 
      Toast.makeText(getApplicationContext(), "Couldn't scan the 
    QRcode, Please Try again ", Toast.LENGTH_SHORT).show(); 

      mScannerView.resumeCameraPreview(this); 
     } 



     // mScannerView.resumeCameraPreview(this); 

     // If you would like to resume scanning, call this method below: 
     //mScannerView.resumeCameraPreview(this); 
    } 
} 
: 나를 인도, 나는 겸허하게 당신의 친절한 도움

을 heres 코드

자바 파일에 대한 기대됩니다

이 같은 그것에 대한 heres는 XML 파일

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.example.tajveezrehman.applicationtest.yourqr"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true"> 

    <Button 
     android:id="@+id/flashlight" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.8" 
     android:text="Button" /> 

    <Button 
     android:id="@+id/open image" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.8" 
     android:text="Button" /> 

    <TextView 
     android:id="@+id/camtxt" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="20dp" 
     android:layout_weight="0.8" 
     android:text="@string/scanner" 
     android:textAlignment="center" 
     android:textColor="#000000" 
     android:textSize="20sp" /> 

    </LinearLayout> 

</RelativeLayout> 

답변

1

사용 RelativeLayout는 : 같은 그 모습

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 

<me.dm7.barcodescanner.zxing.ZXingScannerView 
    android:id="@+id/zxscan" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    /> 

<ImageView 
    android:id="@+id/btn_flash" 
    android:layout_marginBottom="15dp" 
    android:layout_centerHorizontal="true" 
    android:layout_alignParentBottom="true" 
    android:src="@drawable/flash_100" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /> 
:

zxing scanner

+0

응용 프로그램이 충돌주는 '응용 프로그램 중지' –

+0

넣어주세요 ogcat here..so 그래서 오류를 식별 할 수 있습니다 .. –

+0

Logcat을 확인해주세요. –