开发者

Application is crashing

开发者 https://www.devze.com 2023-04-06 15:19 出处:网络
I am working in android. i am designing a custom dialog in which there are two buttons one for close and one for paypal. whenever i press paypal button, this program terminated.

I am working in android. i am designing a custom dialog in which there are two buttons one for close and one for paypal. whenever i press paypal button, this program terminated.

this is my code:-

public class CustomizeDialog extends Dialog implement开发者_开发问答s 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);
        }



    }


}

please check the code and point out what mistake i have done ? Thank you in advance...


This is the solution for the problem:-

@Override public void onClick(View v) { Log.v(TAG, "i am closing tag"); if (v == close) dismiss(); if(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);
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号