我做了一个二维码阅读器,但我需要添加一个按钮 .. 如何以编程方式添加一个按钮?例子:
Button btnVoltar = new Button(this);
    btnVoltar.setText("Voltar");
    btnVoltar.setX(30);
    btnVoltar.setY(30); 
但我需要在视图中添加此按钮。
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if(!isCameraAvailable()) {
        // Cancel request if there is no rear-facing camera.
        cancelRequest();
        return;
    }
    // Hide the window title.
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    mAutoFocusHandler = new Handler();
    // Create and configure the ImageScanner;
    setupScanner();
    // Create a RelativeLayout container that will hold a SurfaceView,
    // and set it as the content of our activity.
    mPreview = new CameraPreview(this, this, autoFocusCB);
    setContentView(mPreview);
}