我正在开发一个应用程序,我使用 ListView 制作日历,就像这篇文章中的图片一样。我已经能够构建 ListView 但我在月份标题和月份中的天数方面遇到了一些问题有人可以在这方面帮助我吗
我的 getView 方法是
public View getView(int pos, View v, ViewGroup p) {
if (DateHelper.isHeaderEnabled(pos,cal)) {
View rowView = mContext.getLayoutInflater().inflate(
R.layout.calendar_list_row_month_header, null);
final TextView headerTextView = (TextView) rowView
.findViewById(R.id.month_header_textView);
SimpleDateFormat sdf = new SimpleDateFormat("MMMM yyyy");
System.out.println(cal.getActualMaximum(Calendar.DAY_OF_MONTH));
cal.setTime(current);
cal.set(Calendar.MONTH, (cal.get(Calendar.MONTH) + pos / 30));
current = cal.getTime();
headerTextView.setText(sdf.format(current));
return rowView;
} else {
View rowView = mContext.getLayoutInflater().inflate(
R.layout.calendar_list_row, null);
TextView dayTextView = (TextView) rowView
.findViewById(R.id.weekDaytextView);
TextView weekDay = (TextView) rowView
.findViewById(R.id.dateTextView);
dayTextView.setText("" + pos % 30);
weekDay.setText(DateHelper.getDayName(pos));
daysPos = daysPos + 1;
return rowView;
}
}
问候
阿尔塔夫