i have this listview
each listview item has a 开发者_StackOverflowtextview that have background , i want to change the background of the textview of listview item get focused .
You should use Selector.
Edit:
Use selector drawable as a background for ListView elements, or specify a android:listSelector for a ListView
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);
}
}
});
精彩评论