use of com.android.calendar.StickyHeaderListView in project Etar-Calendar by Etar-Group.
the class AgendaFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
int screenWidth = mActivity.getResources().getDisplayMetrics().widthPixels;
View v = inflater.inflate(R.layout.agenda_fragment, null);
mAgendaListView = (AgendaListView) v.findViewById(R.id.agenda_events_list);
mAgendaListView.setClickable(true);
if (savedInstanceState != null) {
long instanceId = savedInstanceState.getLong(BUNDLE_KEY_RESTORE_INSTANCE_ID, -1);
if (instanceId != -1) {
mAgendaListView.setSelectedInstanceId(instanceId);
}
}
View eventView = v.findViewById(R.id.agenda_event_info);
if (!mShowEventDetailsWithAgenda) {
eventView.setVisibility(View.GONE);
}
View topListView;
// Set adapter & HeaderIndexer for StickyHeaderListView
StickyHeaderListView lv = (StickyHeaderListView) v.findViewById(R.id.agenda_sticky_header_list);
if (lv != null) {
Adapter a = mAgendaListView.getAdapter();
lv.setAdapter(a);
if (a instanceof HeaderViewListAdapter) {
mAdapter = (AgendaWindowAdapter) ((HeaderViewListAdapter) a).getWrappedAdapter();
lv.setIndexer(mAdapter);
lv.setHeaderHeightListener(mAdapter);
} else if (a instanceof AgendaWindowAdapter) {
mAdapter = (AgendaWindowAdapter) a;
lv.setIndexer(mAdapter);
lv.setHeaderHeightListener(mAdapter);
} else {
Log.wtf(TAG, "Cannot find HeaderIndexer for StickyHeaderListView");
}
// Set scroll listener so that the date on the ActionBar can be set while
// the user scrolls the view
lv.setOnScrollListener(this);
lv.setHeaderSeparator(getResources().getColor(R.color.agenda_list_separator_color), 1);
topListView = lv;
} else {
topListView = mAgendaListView;
}
if (!mShowEventDetailsWithAgenda) {
ViewGroup.LayoutParams params = topListView.getLayoutParams();
params.width = screenWidth;
topListView.setLayoutParams(params);
} else {
ViewGroup.LayoutParams listParams = topListView.getLayoutParams();
listParams.width = screenWidth * 4 / 10;
topListView.setLayoutParams(listParams);
ViewGroup.LayoutParams detailsParams = eventView.getLayoutParams();
detailsParams.width = screenWidth - listParams.width;
eventView.setLayoutParams(detailsParams);
}
return v;
}
Aggregations