onClick不执行任何操作..."ViewPostImeInputStage ACTION_DOWN"; [英] onClick not doing anything... "ViewPostImeInputStage ACTION_DOWN"

查看:303
本文介绍了onClick不执行任何操作..."ViewPostImeInputStage ACTION_DOWN";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用PayPal的应用程序.与SDK相比,我需要使用MPL,因为我的应用程序需要能够实现第三方付款.我遵循了各种教程,并在下面创建了代码.我没有任何编译器错误,也没有日志猫错误,但是当我运行它并单击使用PayPal进行付款"按钮时,没有任何反应.相反,当我单击按钮或屏幕上的任何位置时,都会显示ViewPostImeInputStage ACTION_DOWN.

I'm working on an app that uses PayPal. I need to use the MPL, as opposed to the SDK, because my app needs to be able to implement third-party payments. I've followed various tutorials and created the code below. I don't get any compiler errors, and no log cat error, but when I run it and click on the "Pay with PayPal" button, nothing happens. Instead, I get ViewPostImeInputStage ACTION_DOWN when I click on the button or anywhere on the screen.

我不知道为什么.请帮忙!

I have no idea why. Please help!

public class MainActivity extends Activity implements View.OnClickListener {

private CheckoutButton launchPayPalButton;
final static public int PAYPAL_BUTTON_ID = 10001;
private double _theSubtotal;
private double _taxAmount;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    initLibrary();
    showPayPalButton();
}

private void showPayPalButton() {
    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    ViewGroup.LayoutParams linearLayoutParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    setContentView(linearLayout, linearLayoutParam);

    LayoutParams lpView = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    // Generate the PayPal checkout button and save it for later use
    PayPal pp = PayPal.getInstance();
    launchPayPalButton = pp.getCheckoutButton(this, PayPal.BUTTON_194x37, CheckoutButton.TEXT_PAY);

    // The OnClick listener for the checkout button
    launchPayPalButton.setOnClickListener(this);

    // Add the listener to the layout
    launchPayPalButton.setLayoutParams(lpView);
    launchPayPalButton.setId(PAYPAL_BUTTON_ID);
    linearLayout.addView(launchPayPalButton);

   }

public void PayPalButtonClick(View arg0) {
    PayPalPayment newPayment = new PayPalPayment();
    newPayment.setSubtotal(new BigDecimal(_theSubtotal));
    newPayment.setCurrencyType("USD");
    newPayment.setRecipient("my@email.com");
    newPayment.setMerchantName("My Company");
    Intent paypalIntent = PayPal.getInstance().checkout(newPayment, this);
    this.startActivityForResult(paypalIntent, 2);

}



public void initLibrary() {
    PayPal pp = PayPal.getInstance();

    if (pp == null) {  // Test to see if the library is already initialized

        // This main initialization call takes your Context, AppID, and target server
        pp = PayPal.initWithAppID(this, "APP-80W284485P519543T", PayPal.ENV_NONE);

        // Required settings:

        // Set the language for the library
        pp.setLanguage("en_US");

        // Some Optional settings:

        // Sets who pays any transaction fees. Possible values are:
        // FEEPAYER_SENDER, FEEPAYER_PRIMARYRECEIVER, FEEPAYER_EACHRECEIVER, and FEEPAYER_SECONDARYONLY
        pp.setFeesPayer(PayPal.FEEPAYER_EACHRECEIVER);

        // true = transaction requires shipping
        pp.setShippingEnabled(false);


    }

}

@Override
public void onClick(View arg0){

    PayPalButtonClick(arg0);
}

}

推荐答案

ViewPostImeInputStage ACTION_DOWN基本上是一种条件,当您的布局被拒绝并且您不再能够单击任何可单击的项时,解决方案很简单,只需将布局内容与父项一起包裹即可.

ViewPostImeInputStage ACTION_DOWN is basically a condition when your layout is rejected and you are no longer be able to click on any clickable items.The solution for this is simple, just wrap your layout contents with a parent.

例如:

if you have the xml with format as:
<LinearLayout <---root layout
 ..... contents here
</LinearLayout> <-- root layout end

change to 

<FrameLayout <---root layout
   <LinearLayout <-- parent wrap start
   ...
<!-- your content -->
   </LinearLayout> <-- parent wrap end
</FrameLayout> <-- root layout end

有关更多信息,您可以考虑阅读

for more information, you might wana consider reading this

这篇关于onClick不执行任何操作..."ViewPostImeInputStage ACTION_DOWN";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆