将文本编辑为changecontact
edittext焦点在android studio中不起作用,我想在edittext中焦点改变时隐藏一个textview,如何做到这一点?
ChangeContact.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
Toast.makeText(mContext, "focus loosed", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(mContext, "focused", Toast.LENGTH_LONG).show();
bookLinear.setVisibility(View.GONE);
}
}
});
在xml文件中编辑文本
<EditText
android:id="@+id/etChangeAddress"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginBottom="8dp"
android:background="@drawable/shape_transparent"
android:ems="10"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:hint="Address"
android:inputType="textPersonName"
android:padding="5dp"
app:layout_constraintBottom_toTopOf="@+id/etChangeNumber"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
但我看不到祝酒词
请帮忙。。。。
1条答案
按热度按时间vqlkdk9b1#
你试过用这个换联系人吗?
同时更改contact.requestfocus()?