【问题标题】:Java.Lang.NoSuchMethodError: no non-static method "Landroid/widget/CompoundButton Xamarin.AndroidJava.Lang.NoSuchMethodError:没有非静态方法“Landroid/widget/CompoundButton Xamarin.Android
【发布时间】:2017-05-23 17:59:09
【问题描述】:

我收到此错误:

Java.Lang.NoSuchMethodError: 没有非静态方法“Landroid/widget/CompoundButton;.getButtonDrawable()Landroid/graphics/drawable/Drawable;

当我像这样使用单选按钮 ButtonDrawable 时:

    if(myRadioButton.ButtonDrawable == null)
    {
        //Do Something
    }

我在 android API = 23 (Marshmallow) 上测试了该应用,它运行良好。对于 android API

我正在使用 Xamarin.Android.Support.Design 版本 25.3.1

有解决办法吗?

【问题讨论】:

    标签: android xamarin.android radio-button nosuchmethoderror


    【解决方案1】:

    我在 android API = 23 (Marshmallow) 上测试了该应用程序,它运行良好。对于 android API

    这是预期的行为。如果你参考 ButtonDrawable。此 API 是在 API 级别 23 中添加的。

    【讨论】:

      【解决方案2】:

      猫王是正确的,这是我的错误。 如果有人遇到同样的问题,这就是我在不使用 get button drawable 的情况下解决问题的方法。

      此代码适用于 Xamarin.android,但您可以将其转换为 Java。

      //Remove radio button circle    
       radioButton.SetButtonDrawable(new StateListDrawable());
      
      //Set tag = true to know the button drawable is null
      radioButton.Tag = true;
      

      后面的代码:

      if(radioButton.tag.Equals(true))
      {
         //Do something
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-09-05
        • 2018-04-10
        • 2018-04-17
        • 1970-01-01
        • 2017-11-13
        • 2023-03-02
        • 1970-01-01
        相关资源
        最近更新 更多