as shown below in the code, i have some views and i want to add a selector color to the view, so that when the view is clicked its color changes. exactly as happens when one clicks on an item in a listview, that's what i am trying to do.
i referred to some posts and i troed both of the following:
view.setBackgroundResource(android.R.attr.listChoiceBackgroundIndicator);//highlighted with red color
view.setBackground(android.R.attr.listChoiceBackgroundIndicator);//highlighted with red color
but it doesnt work and AndroidStudio highlight them with red color.
please let me know how to add a selector color to my vies programmatically
code:
LayoutInflater inflator = this.getLayoutInflater();
final View view = inflator.inflate(R.layout.versicherungs_docs_footer, null);
RelativeLayout relLay = (RelativeLayout) view.findViewById(R.id.versicherungslisteactivity2_meinedocs_lisvie_footer_mainContainer);
final TextView texVieShowMore = (TextView) view.findViewById(R.id.versicherungslisteactivity2_meinedocs_lisvie_footer_texVie_showMore);
final TextView texVieShowLess = (TextView) view.findViewById(R.id.versicherungslisteactivity2_meinedocs_lisvie_footer_texVie_showLess);
final TextView texVieShowMoreArrow = (TextView) view.findViewById(R.id.versicherungslisteactivity2_meinedocs_lisvie_footer_texVie_showMoreArrow);
final TextView texVieShowLessArrow = (TextView) view.findViewById(R.id.versicherungslisteactivity2_meinedocs_lisvie_footer_texVie_showLessArrow);
view.setBackgroundResource(android.R.attr.listChoiceBackgroundIndicator);//highlighted with red color
//view.setBackground(android.R.attr.listChoiceBackgroundIndicator);//highlighted with red color