Answer the question
In order to leave comments, you need to log in
Why is OnFocusChange not working?
public class EditNoteActivity extends AppCompatActivity implements View.OnFocusChangeListener {
private String TAG = "EditNote";
EditText edtNoteTitle;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_note);
edtNoteTitle = findViewById(R.id.edt_note_title);
edtNoteTitle.setOnFocusChangeListener((v, f) -> {
Log.d(TAG, "1"); // Выводится
});
}
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (v.getId() == R.id.edt_note_title) {
Log.d(TAG, "2"); // Не выводится
}
}
}
Answer the question
In order to leave comments, you need to log in
You have set listener to "1" only.
If you want to call "2" write edtNoteTitle.setOnFocusChangeListener(this)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question