Я использую класс Fragment
, в котором я хочу изменить цвет TextView
Когда EditText
пуст после его изменения. Я могу изменить цвет TextView
при изменении текста, но когда текст будет чистым, цвет фона TextView
не изменится на предыдущий. Каковы возможные способы изменения цвета фона TextView
Когда EditText
пуст после изменения текста. Мой код выглядит следующим образом:Как изменить цвет фона TextView, если EditText пуст в android?
public class Fragment_AboutUs extends android.app.Fragment {
TextView about_btn_call_customer;
TextView about_btn_Submit;
EditText about_feedback;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.layout_fragment_about_us, container, false);
//reference section
about_btn_call_customer= (TextView) rootView.findViewById(R.id.about_btn_call_customer);
about_btn_Submit=(TextView)rootView.findViewById(R.id.about_btn_Submit);
about_feedback=(EditText)rootView.findViewById(R.id.about_feedback);
TextWatcher textWatcher = new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
String textinEdit= about_feedback.getText().toString().trim();
if (textinEdit != null) {
about_btn_Submit.setBackgroundColor(getResources().getColor(R.color.light_green));
}else if (textinEdit ==""){
about_feedback.setBackgroundColor(getResources().getColor(R.color.grayColor));
}
}
};
about_feedback.addTextChangedListener(textWatcher);
return rootView;
}
}
Спасибо заранее ... любая помощь была бы оценена ...
я попробовал свое решение, он работал как шарм, спасибо –
вы можете – Blackbelt