在TextInputLayout中找不到setEndIconOnClickListener方法

时间:2019-10-16 11:20:10

标签: android android-textinputlayout android-textinputedittext

我在活动布局中使用TextInputLayout和TextInputEditText。这是我的xml代码:

<com.google.android.material.textfield.TextInputLayout
   android:layout_width="@dimen/login_width"
   android:layout_height="wrap_content"
   android:layout_gravity="center"
   android:layout_marginTop="@dimen/password_margin_top"
   app:hintEnabled="false"
   app:passwordToggleDrawable="@drawable/password_toggle_drawable"
   app:passwordToggleEnabled="true">

   <com.google.android.material.textfield.TextInputEditText
      android:id="@+id/my_login_password"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:fontFamily="sans-serif"
      android:hint="@string/password"
      android:inputType="textPassword"
      android:nextFocusDown="@+id/my_login_login"
      android:padding="@dimen/field_padding" />

</com.google.android.material.textfield.TextInputLayout>

我想在单击密码切换图标时进行回调。我在-documentation

上找到了

当我从文本输入布局中调用此方法时,它显示cannot resolve symbol

添加我的代码示例: 导入的类:import com.google.android.material.textfield.TextInputEditText; import com.google.android.material.textfield.TextInputLayout; 变量声明:private TextInputLayout passwordTextInputLayout;

使用方法

methode pic

所有与结束图标相关的方法均不可访问。这些方法被删除了吗?

编辑:我只是反编译TextInputLayout类并检查了方法,所以无法在其中找到所提到的方法。

1 个答案:

答案 0 :(得分:0)

我正在使用材料库的1.0.0版本。 setEndIconOnClickListener方法在1.1.0版中引入(尚未发布1.1.0的稳定版本)。因此,我使用了最新的Beta版本来解决我的问题。

implementation 'com.google.android.material:material:1.1.0-beta01'