在 TextInputLayout 中找不到 setEndIconOnClickListener 方法
setEndIconOnClickListener method not found in TextInputLayout
我在 activity 布局中使用 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
。
添加我的代码示例:
导入 class:import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
变量声明:private TextInputLayout passwordTextInputLayout;
方法用法
所有结束图标相关的方法都无法访问。那些方法被删除了?
编辑:我刚刚反编译了 TextInputLayout class 并检查了方法,我无法在其中找到提到的方法。
我使用的是 material 库的 1.0.0 版本。 setEndIconOnClickListener 方法是在 1.1.0 版本中引入的(尚未发布 1.1.0 的稳定版本)。所以,我已经使用最新的测试版来解决我的问题。
implementation 'com.google.android.material:material:1.1.0-beta01'
我在 activity 布局中使用 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
。
添加我的代码示例:
导入 class:import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
变量声明:private TextInputLayout passwordTextInputLayout;
方法用法
所有结束图标相关的方法都无法访问。那些方法被删除了?
编辑:我刚刚反编译了 TextInputLayout class 并检查了方法,我无法在其中找到提到的方法。
我使用的是 material 库的 1.0.0 版本。 setEndIconOnClickListener 方法是在 1.1.0 版本中引入的(尚未发布 1.1.0 的稳定版本)。所以,我已经使用最新的测试版来解决我的问题。
implementation 'com.google.android.material:material:1.1.0-beta01'