Reputation: 1971
Is there anyway to establish a relationship between an edittext and textview that is inside a table row? The purpose is to change the color of textview while the edittext is clicked. Some kind of parent child relationship is possible? Any clue? Thanks.
Upvotes: 0
Views: 51
Reputation: 2644
Try this, when EditText
will be in focus TextView
color will get changed, and on focusing other view color will get changed again.
editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean isFocused) {
textView.setTextColor(isFocused ? ContextCompat.getColor(this, R.color.bg_red) : ContextCompat.getColor(R.color.bg_blue));
}
});
Upvotes: 1
Reputation: 80
You can either use onClickListener or addTextWatcher on Edittext to achieve required behavior.
Upvotes: 1