我有歌曲列表,并要突出(变化的背景),这首歌是目前playing.It应该能够当我的歌完成就可以更改背景并进入下一个。当我选择任何列表视图项目时,我也希望更改背景。 有人请指导我如何前进与此。 代码: -更改列表视图项目背景动态
我implmenting这个代码,但多个列表项的颜色变化
@Override
public void bindView(View view, Context context, Cursor cursor) {
// TODO Auto-generated method stub
super.bindView(view, context, cursor);
final View vi=inflater.inflate(layout, null, false);
TextView titleS=(TextView)view.findViewById(R.id.TitleSong);
TextView artistS=(TextView)view.findViewById(R.id.Artist);
int Title_index;
int Artist_index;
Title_index=cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DISPLAY_NAME);
Artist_index=cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST);
titleS.setText(cursor.getString(Title_index));
artistS.setText(cursor.getString(Artist_index));
if(cursor.getPosition()==MainActivity.songPosition){
titleS.setBackgroundColor(Color.BLUE);
}
}
查看是否添加'else'语句一起去了'if'帮助。添加'else {titleS.setBackgroundColor(Color.WHITE); }'。 – Vikram
感谢它现在的工作。 –