Reputation: 8035
My row for listview is defined in its own xml file. It contains some textviews.
How can i set the text color of these textviews based on the state of the row (selected , focused, normal ...)?
Upvotes: 2
Views: 385
Reputation: 2568
If you are setting adapter for listview in your code then override getView of your adapter like this:
adapter = new ArrayAdapter<String>(YourActivity.this , R.layout.liststylelayout)
{
@Override
public View getView(int position, View convertView,ViewGroup parent)
{
View v = super.getView(position, convertView, parent);
//v is parent view which has your textview as child
TextView tv1 =(TextView)v.findViewById(R.id.movielistitemstrings);
//get your textview like this
tv1.setTextColor(Color.parseColor("#FF8000"));
//do your operations on textview
}
};
Upvotes: 0
Reputation: 29121
you have to use setOnFocusChangedListener() for each row . and get access to your textViews, and change the text color.
row.setOnFocusChangedListener(focuschangedListener);
private onFocusChangedListener focustchangedListener = new onFocusChangedListener(
@Override
public void onFocusChange(View row, boolean arg1) {
//get access to textviews using row.findViewById()
if (arg1) {
// view is on focus, change the textcolor
} else {
// view lost focus, change the text colors to normal.
}
}
);
Upvotes: 1