我正在使用贝宝付款,因为我必须在 onCreate() 方法中运行线程,该方法使用贝宝图像初始化按钮......这个文件不是空白的。” 但在此之后,当我更正该字段并再次单击 Btn 时,它什么也不做。
Thread libraryInitializationThread = new Thread() {
public void run() {
initLibrary();
// The library is initialised so let's create our CheckoutButton
// and update the UI.
if (PayPal.getInstance().isLibraryInitialized()) {
runOnUiThread(new Runnable() {
public void run() {
/**
* Create our CheckoutButton and update the UI.
*/
PayPal pp = PayPal.getInstance();
/**
* Get the CheckoutButton. There are five
* differentsizes. The text on the button can either
* be of type TEXT_PAY or TEXT_DONATE.
**/
launchChainedPaymentBtn = pp.getCheckoutButton(
BuyDeal.this, PayPal.BUTTON_194x37,
CheckoutButton.TEXT_PAY);
/**
* You'll need to have an OnClickListener for the
* CheckoutButton. For this application, MPL_Example
* implements OnClickListener and we have the
* onClick() method below.
**/
launchChainedPaymentBtn
.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// dealResponse
getDealResponseLogic();
}
});
//
BottomBtnsLinearLayout
.addView(launchChainedPaymentBtn);
Log.v("Btn added ", "SuccessFully...");
Flag = true;
}
});
//
//
BottomBtnsLinearLayout.addView(launchChainedPaymentBtn);
Log.v("Btn added ", "SuccessFully...");
// }
// });
Log.i("Lib. initialized", "now...");
/** Calling Thread to add Btn to It! **/
AddPayPalBtn.start();
} else {
Log.i("Cannot Initialize Payment Btn",
"setAPyment Btn..failed due to Lib. initialization..");
}
}
};
libraryInitializationThread.start();
我在我的活动的 onCreate() 方法中调用了上面的线程。
dealResponseLogic() 的代码只处理验证。
初始化库();它让 PayPal 实例利用互联网,然后设置该实例的一些字段。
我知道我可以从那个 btn 监听器代码 btn 调用那个线程,我正在寻找另一种方式。
请...任何帮助将不胜感激...