Reputation: 13327
i have this listview
each listview item has a textview that have background , i want to change the background of the textview of listview item get focused .
Upvotes: 0
Views: 640
Reputation: 8935
You should use Selector.
Edit:
Use selector drawable as a background for ListView elements, or specify a android:listSelector for a ListView
Upvotes: 1
Reputation: 6037
you have change background color in onfocusChangeListener. Try with following code,
livView.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
TextView tv=(TextView)v.findViewById(R.id.yourId);
if(hasFocus){
tv.setBackgroundColor(bg_color);
}
}
});
Upvotes: 0