我正在制作一个通过PayPal接受捐赠的Android应用程序。功能一切正常。但是,当我开始我的捐赠活动时,大约需要6-7秒才能打开。我不知道为什么。难道是我编程式地将PayPal CheckoutButton添加到我的布局中,而不是将它添加到xml中?Android PayPal按钮的性能问题
这里是我正在添加按钮:
// PayPal Button
PayPal ppObj = PayPal.initWithAppID(this, "APP-ID", PayPal.ENV_LIVE);
CheckoutButton launchPayPalButton = ppObj.getCheckoutButton(this, PayPal.BUTTON_278x43, CheckoutButton.TEXT_DONATE);
launchPayPalButton.setOnClickListener(this);
// Place PayPal Button in Layout
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
params.addRule(RelativeLayout.CENTER_HORIZONTAL);
params.topMargin = 10;
launchPayPalButton.setLayoutParams(params);
((RelativeLayout)findViewById(R.id.donateRelativeLayout)).addView(launchPayPalButton);
有没有办法在XML做到这一点?这甚至是性能问题的原因吗?
你能找出哪条线负责? – WarrenFaith 2011-12-22 12:06:03