0
mCalendarModel의 데이터는 어댑터를 통해 아래의 목록보기를 채우는 데 사용됩니다. 문제는 해당 연도에 해당하는 모든 데이터에 대해 한 달 만 표시해야한다는 것입니다. 예를 들어 :끈끈한 목록보기 채우기 안드로이드
*Current result:
Header -> January
Item -> Series St Pierre
Header -> January
Item -> Series St Pierre
Header -> January
Item -> Series St Pierre
Header -> February
Item -> Series St Aubin
Expected Result:
Header -> January
Item -> Series St Pierre
Item -> Series St Pierre
Item -> Series St Pierre
Item -> Series St Pierre
Item -> Series St Pierre
Item -> Series St Pierre
Item -> Series St Pierre
Item -> Series St Pierre
Item -> Series St Pierre
Header -> February
Item -> Series St Aubin
...*
는 왜 확장 목록보기를 시도 해달라고 만 예상 된 결과를
*mCalendarModel = new ArrayList<CalendarModel>();
mCalendarModel.add(new CalendarModel("JANVIER", "Dimanche 2/01", "Series St Pierre", "22 km", "$1000", "course_trail","1","1"));
mCalendarModel.add(new CalendarModel("JANVIER", "Dimanche 2/01", "Series St Pierre", "22 km", "$1000", "course_trail","1","1"));
mCalendarModel.add(new CalendarModel("JANVIER", "Dimanche 2/01", "Series St Pierre", "22 km", "$1000", "course_trail","1","1"));
mCalendarModel.add(new CalendarModel("JANVIER", "Dimanche 2/01", "Series St Pierre", "22 km", "$1000", "course_trail","1","1"));
mCalendarModel.add(new CalendarModel("JANVIER", "Dimanche 2/01", "Series St Pierre", "22 km", "$1000", "course_trail","1","1"));
mCalendarModel.add(new CalendarModel("JANVIER", "Dimanche 2/01", "Series St Pierre", "22 km", "$1000", "course_trail","1","1"));
mCalendarModel.add(new CalendarModel("JANVIER", "Dimanche 2/01", "Series St Pierre", "22 km", "$1000", "course_trail","1","1"));
mCalendarModel.add(new CalendarModel("JANVIER", "Dimanche 2/01", "Series St Pierre", "22 km", "$1000", "course_trail","1","1"));
mCalendarModel.add(new CalendarModel("JANVIER", "Dimanche 2/01", "Series St Pierre", "22 km", "$1000", "course_trail","1","1"));
mCalendarModel.add(new CalendarModel("JANVIER", "Dimanche 2/01", "Series St Pierre", "22 km", "$1000", "course_trail","1","1"));
mCalendarModel.add(new CalendarModel("JANVIER", "Samedi 3/01", "Series St Aubin", "22 km", "$1000", "course_route","1","1"));
mCalendarModel.add(new CalendarModel("JANVIER", "Samedi 2/01", "Series St Aubin", "22 km", "$1000", "course_route","1","1"));
mCalendarModel.add(new CalendarModel("JANVIER", "Samedi 2/01", "Series St Aubin", "22 km", "$1000", "course_route","2","1"));
mCalendarModel.add(new CalendarModel("JANVIER", "Samedi 2/01", "Series St Aubin", "22 km", "$1000", "course_route","1","1"));
mCalendarModel.add(new CalendarModel("FEVRIER", "Samedi 2/01", "Series St Aubin", "22 km", "$1000", "course_route","2","2"));*
public void populateHeaderList(){
SectionAdapter sectionAdapter = new SectionAdapter(getActivity(), mCalendarModel,mLayoutInflator){
private ViewHeaderHolder headHolder;
@Override
public int numberOfSections() {
return mCalendarModel.size();
}
@Override
public int numberOfRows(int section) {
return 1;
}
@Override
public String getRowItem(int section, int row) {
return null;
}
@Override
public boolean hasSectionHeaderView(int section) {
return true;
}
@Override
public int getSectionHeaderViewTypeCount() {
return 2;
}
@Override
public int getSectionHeaderItemViewType(int section) {
return section % 2;
}
@SuppressLint("InflateParams")
@Override
public View getSectionHeaderView(int section, View convertView, ViewGroup parent) {
View vi = convertView;
if (convertView == null) {
vi = mLayoutInflator.inflate(R.layout.header_row_field, null);
headHolder = new ViewHeaderHolder();
headHolder.mTextHeader = (Button) vi.findViewById(R.id.mTextHeader);
vi.setTag(headHolder);
} else
headHolder = (ViewHeaderHolder) vi.getTag();
headHolder.mTextHeader.setText(mCalendarModel.get(section).month);
headHolder.mTextHeader.setTextColor(getResources().getColor(R.color.calendrier_vert));
return vi;
}
@Override
public void onRowItemClick(AdapterView<?> parent, View view, int section, int row, long id) {
super.onRowItemClick(parent, view, section, row, id);
Intent intentFicheCourse = new Intent (getActivity(),FicheCourse.class);
startActivity(intentFicheCourse);
getActivity().overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
}
@SuppressLint("InflateParams")
@Override
public View getRowView(int section, int row, View convertView,
ViewGroup parent) {
// TODO Auto-generated method stub
View vi = convertView;
if (convertView == null) {
vi = mLayoutInflator.inflate(R.layout.header_row_item, null);
holder = new ViewHolder();
holder.mTextDate = (TextView) vi.findViewById(R.id.mTextDate);
holder.mTextAddress = (TextView) vi.findViewById(R.id.mTextAddress);
holder.mTextDistance = (TextView) vi.findViewById(R.id.mTextDistance);
holder.mTextTarif = (TextView) vi.findViewById(R.id.mTextTarif);
//holder.mLDivider= (LinearLayout) vi.findViewById(R.id.mLDivider);
vi.setTag(holder);
} else
holder = (ViewHolder) vi.getTag();
holder.mTextDate.setText(mCalendarModel.get(row).date);
holder.mTextAddress.setText(mCalendarModel.get(row).title);
holder.mTextTarif.setText(mCalendarModel.get(row).tarrif);
holder.mTextDistance.setText(mCalendarModel.get(row).distance);
return vi;
}
};
mHeaderList.setAdapter(sectionAdapter);
}
하지만 끈적한 헤더가 없습니다. – Dimitri
끈적 헤더 란 정확히 무엇을 의미합니까? 1 월 1 일이 항상 정상에 오길 원하니? –
을 참조하십시오. http://applidium.github.io/HeaderListView/ – Dimitri