我正在做paypal付款,因爲我必須在onCreate()方法中初始化Button與PayPal圖像我調用一個函數從它驗證上述字段,然後觸發一個API ,如果用戶錯誤的Toast出現了「......這個提交不是空白的」。但之後,當我糾正該領域,再次點擊Btn,然後它什麼都不做。onClickListener不會被第二次調用Android
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()只處理驗證的代碼。
initLibrary();它使PayPal實例利用互聯網,然後設置該實例的一些字段。
我知道我可以調用該線程從該btn監聽器代碼btn我正在尋找另一種方式。
請...任何幫助將不勝感激......
請問您可以上傳代碼嗎? – Lucifer
你能發表一些代碼嗎?我不明白什麼問題確切地是 – zeiger
我加了代碼,請檢查... – MobileEvangelist