我有一个列表视图,我正在使用消息更新,就像android收件箱消息一样,我想保持列表视图项突出显示,直到它被打开或单击一次,我填充列表视图的代码是:
List<Message> values = datasource.getAllMessages(ch);
Collections.reverse(values);
ArrayAdapter<Message> adapter = new ArrayAdapter<Message>(getActivity(), android.R.layout.simple_list_item_1, values);
setListAdapter(adapter);
函数getAllMessages从数据库中获取值以填充列表, 在此先感谢!!!
答案 0 :(得分:0)
您需要通过扩展ArrayAdapter类来创建自定义适配器,以实现:
private class Adapter extends ArrayAdapter<String>
{
public Adapter(Context context, int resource, int textViewResourceId, String[] strings)
{
super(context, resource, textViewResourceId, strings);
}
public View getView(int position, View convertView, ViewGroup viewGroup)
{
View view = getLayoutInflater().inflate(R.layout.row_layout, null);
.......
//do the logic of highlighting each row
return view
}