【发布时间】:2016-05-06 06:42:59
【问题描述】:
我有一个片段,即 ScheduledFragment,在那个片段中我有一个自定义列表视图。正在从服务器获取值并将这些值插入到列表项中。
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_scheduled, container, false);
final ArrayList<CoursePojo> searchResults = GetSearchResults();
final ListView lv1 = (ListView) rootView.findViewById(R.id.lvList2);
lv1.setAdapter(new MyCustomCourseList(getActivity(), searchResults));
lv1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
Object o = lv1.getItemAtPosition(position);
String currentid = ids.get(position);
String currentcourse = cs.get(position);
CoursePojo fullObject = (CoursePojo) o;
}
});
return rootView;}
正在将值添加到数组列表中。 MyCustomCourseList 适配器类 getView() 如下所示
public View getView(int position, View convertView, ViewGroup parent) {
View view=convertView;
ViewHolder holder;
if (convertView == null) {
holder.relativeLayout=(RelativeLayout)convertView.findViewById(R.id.rel1);
else {
holder = (ViewHolder) convertView.getTag();
}
holder.relativeLayout.setBackgroundColor(convertView.getResources().getColor(R.color.textColorPrimary));
这是为我的整个自定义列表设置颜色。但我真正需要的是从服务器获取一些日期,我需要更改某些日期的列表项的背景颜色。在比较从服务器获得的日期和当前日期之后,我需要更改这些列表项的颜色。当前日期之前的日期必须以背景颜色“主要颜色”显示,当前日期之后的日期必须以颜色“次要颜色”显示
【问题讨论】:
标签: android date listview android-fragments