应用程序崩溃了

时间:2011-09-21 11:54:04

标签: android

我在android工作。我正在设计一个自定义对话框,其中有两个按钮用于关闭,一个用于paypal。每当我按下paypal按钮,该程序就会终止。

这是我的代码: -

public class CustomizeDialog extends Dialog implements OnClickListener {

    Button close;

    String TAG="CustomizeDialog";



    Context customize_dialog;

    CheckoutButton launchSimplePayment;

    public CustomizeDialog(Context context) {
        super(context);
        /** It will hide the title */
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        customize_dialog=context;
        setContentView(R.layout.paypal_custom_dialog);
        close = (Button) findViewById(R.id.paypal_close);
        text_view_price.setText("Price : "+price_of_song);

        PayPal pp = PayPal.getInstance();
        if (pp == null) {
            try {
                pp = PayPal.initWithAppID(context, "", PayPal.ENV_NONE);
            } catch (IllegalStateException e) {
                throw new RuntimeException(e);
            }
            pp.setShippingEnabled(false);
        }




        launchSimplePayment = pp.getCheckoutButton(context,

        PayPal.BUTTON_118x24, CheckoutButton.TEXT_PAY);

        LinearLayout lnr = (LinearLayout) findViewById(R.id.Paypal_Custom_Dialog_View);


        launchSimplePayment.setOnClickListener( this);


        lnr.addView(launchSimplePayment);




        close.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        Log.v(TAG, "i am closing tag");
        if (v == close)
            dismiss();
        if(v==launchSimplePayment)
        {
            dismiss();
            PayPalPayment payment = new PayPalPayment();

            payment.setSubtotal(new BigDecimal("2.25"));

            payment.setCurrencyType("USD");

            payment.setRecipient("kuntal_1316186174_biz@gmail.com");

            payment.setPaymentType(PayPal.PAYMENT_TYPE_GOODS);

            Intent checkoutIntent = PayPal.getInstance().checkout(payment,customize_dialog);

            ((Activity) customize_dialog).startActivityForResult(checkoutIntent, 1);
        }



    }


}

请检查代码并指出我做了什么错误? 提前谢谢你......

1 个答案:

答案 0 :(得分:0)

这是问题的解决方案: -

@覆盖     public void onClick(查看v){         Log.v(TAG,“我正在关闭标签”);         如果(v ==关闭)             解雇();         如果(V == launchSimplePayment)         {

        PayPalPayment payment = new PayPalPayment();

        payment.setSubtotal(new BigDecimal("2.25"));

        payment.setCurrencyType("USD");

        payment.setRecipient("kuntal_1316186174_biz@gmail.com");

        payment.setPaymentType(PayPal.PAYMENT_TYPE_GOODS);

        Intent checkoutIntent = PayPal.getInstance().checkout(payment,customize_dialog);

        ((Activity) customize_dialog).startActivityForResult(checkoutIntent, 1);
    }