edittext焦点在android studio中不起作用,我想在edittext中焦点改变时隐藏一个textview,怎么做?

gt0wga4j  于 2021-07-03  发布在  Java
关注(0)|答案(1)|浏览(388)

将文本编辑为changecontact
edittext焦点在android studio中不起作用,我想在edittext中焦点改变时隐藏一个textview,如何做到这一点?

  1. ChangeContact.setOnFocusChangeListener(new View.OnFocusChangeListener() {
  2. @Override
  3. public void onFocusChange(View v, boolean hasFocus) {
  4. if (!hasFocus) {
  5. Toast.makeText(mContext, "focus loosed", Toast.LENGTH_LONG).show();
  6. } else {
  7. Toast.makeText(mContext, "focused", Toast.LENGTH_LONG).show();
  8. bookLinear.setVisibility(View.GONE);
  9. }
  10. }
  11. });

在xml文件中编辑文本

  1. <EditText
  2. android:id="@+id/etChangeAddress"
  3. android:layout_width="0dp"
  4. android:layout_height="wrap_content"
  5. android:layout_marginStart="6dp"
  6. android:layout_marginBottom="8dp"
  7. android:background="@drawable/shape_transparent"
  8. android:ems="10"
  9. android:focusable="true"
  10. android:focusableInTouchMode="true"
  11. android:gravity="center"
  12. android:hint="Address"
  13. android:inputType="textPersonName"
  14. android:padding="5dp"
  15. app:layout_constraintBottom_toTopOf="@+id/etChangeNumber"
  16. app:layout_constraintEnd_toEndOf="parent"
  17. app:layout_constraintStart_toStartOf="parent" />

但我看不到祝酒词
请帮忙。。。。

vqlkdk9b

vqlkdk9b1#

你试过用这个换联系人吗?

  1. android:focusable="true"
  2. android:focusableInTouchMode="true"

同时更改contact.requestfocus()?

相关问题