List of usage examples for android.widget ListView getHeaderViewsCount
@Override public int getHeaderViewsCount()
From source file:eu.trentorise.smartcampus.eb.fragments.experience.EditExpFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { returnView = inflater.inflate(R.layout.exp_form, container, false); ListView list = (ListView) returnView.findViewById(R.id.exp_contents); registerForContextMenu(list);/* w ww .j ava 2 s.co m*/ if (list.getFooterViewsCount() == 0) { View footer = getSherlockActivity().getLayoutInflater().inflate(R.layout.exp_form_footer, null); list.addFooterView(footer, null, false); } if (list.getHeaderViewsCount() == 0) { View header = getSherlockActivity().getLayoutInflater().inflate(R.layout.exp_form_header, null); list.addHeaderView(header, null, false); mTitleSwitch = new TextEditSwitch(returnView, R.id.title_switcher, R.id.title_tv, R.id.title, this); mTitleSwitch.setValue(exp.getTitle()); mDescrSwitch = new TextEditSwitch(returnView, R.id.descr_switcher, R.id.description_tv, R.id.description, this); mDescrSwitch.setValue(exp.getDescription()); } adapter = new ExpContentAdapter(getSherlockActivity(), R.layout.exp_contents_row, exp.getContents()); list.setAdapter(adapter); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position <= exp.getContents().size() && position > 0) { ContentRenderer.renderExternal(getActivity(), exp.getContents().get(position - 1)); } } }); updateCollectionTV(); if (exp.getId() == null) { new LoadAddressTask().execute(); } else { updateFooterTV(exp.getAddress(), exp.getCreationTime()); } if (exp.getTags() != null) { ((TextView) returnView.findViewById(R.id.tags_tv)).setText(Concept.toSimpleString(exp.getTags())); } ((TextView) returnView.findViewById(R.id.tags_tv)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { TaggingDialogFragment taggingDialog = new TaggingDialogFragment(); taggingDialog.setArguments(TaggingDialogFragment.prepare(Concept.convertToSS(exp.getTags()))); taggingDialog.show(getActivity().getSupportFragmentManager(), "tags"); } }); returnView.findViewById(R.id.place_box).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { DialogFragment textFragment = new EditPositionFragment(); textFragment.setArguments( EditPositionFragment.prepare(exp.getAddress() == null ? "" : exp.getAddress())); textFragment.show(getActivity().getSupportFragmentManager(), "exp_position"); } }); return returnView; }
From source file:org.mozilla.gecko.home.TopSitesPanel.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { mEditPinnedSiteListener = new EditPinnedSiteListener(); mList.setTag(HomePager.LIST_TAG_TOP_SITES); mList.setHeaderDividersEnabled(false); mList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//from ww w .j a v a 2 s. c om public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final ListView list = (ListView) parent; final int headerCount = list.getHeaderViewsCount(); if (position < headerCount) { // The click is on a header, don't do anything. return; } // Absolute position for the adapter. position += (mGridAdapter.getCount() - headerCount); final Cursor c = mListAdapter.getCursor(); if (c == null || !c.moveToPosition(position)) { return; } final String url = c.getString(c.getColumnIndexOrThrow(TopSites.URL)); Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.LIST_ITEM); // This item is a TwoLinePageRow, so we allow switch-to-tab. mUrlOpenListener.onUrlOpen(url, EnumSet.of(OnUrlOpenListener.Flags.ALLOW_SWITCH_TO_TAB)); } }); mList.setContextMenuInfoFactory(new HomeContextMenuInfo.Factory() { @Override public HomeContextMenuInfo makeInfoForCursor(View view, int position, long id, Cursor cursor) { final HomeContextMenuInfo info = new HomeContextMenuInfo(view, position, id); info.url = cursor.getString(cursor.getColumnIndexOrThrow(TopSites.URL)); info.title = cursor.getString(cursor.getColumnIndexOrThrow(TopSites.TITLE)); info.historyId = cursor.getInt(cursor.getColumnIndexOrThrow(TopSites.HISTORY_ID)); info.itemType = RemoveItemType.HISTORY; final int bookmarkIdCol = cursor.getColumnIndexOrThrow(TopSites.BOOKMARK_ID); if (cursor.isNull(bookmarkIdCol)) { // If this is a combined cursor, we may get a history item without a // bookmark, in which case the bookmarks ID column value will be null. info.bookmarkId = -1; } else { info.bookmarkId = cursor.getInt(bookmarkIdCol); } return info; } }); mGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { TopSitesGridItemView item = (TopSitesGridItemView) view; // Decode "user-entered" URLs before loading them. String url = StringUtils.decodeUserEnteredUrl(item.getUrl()); int type = item.getType(); // If the url is empty, the user can pin a site. // If not, navigate to the page given by the url. if (type != TopSites.TYPE_BLANK) { if (mUrlOpenListener != null) { final TelemetryContract.Method method; if (type == TopSites.TYPE_SUGGESTED) { method = TelemetryContract.Method.SUGGESTION; } else { method = TelemetryContract.Method.GRID_ITEM; } Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, method, Integer.toString(position)); // Record tile click events on non-private tabs. final Tab tab = Tabs.getInstance().getSelectedTab(); if (!tab.isPrivate()) { final Locale locale = Locale.getDefault(); final String localeTag = Locales.getLanguageTag(locale); TilesRecorder.recordAction(tab, TilesRecorder.ACTION_CLICK, position, getTilesSnapshot(), localeTag); } mUrlOpenListener.onUrlOpen(url, EnumSet.noneOf(OnUrlOpenListener.Flags.class)); } } else { if (mEditPinnedSiteListener != null) { mEditPinnedSiteListener.onEditPinnedSite(position, ""); } } } }); mGrid.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Cursor cursor = (Cursor) parent.getItemAtPosition(position); TopSitesGridItemView item = (TopSitesGridItemView) view; if (cursor == null || item.getType() == TopSites.TYPE_BLANK) { mGrid.setContextMenuInfo(null); return false; } TopSitesGridContextMenuInfo contextMenuInfo = new TopSitesGridContextMenuInfo(view, position, id); updateContextMenuFromCursor(contextMenuInfo, cursor); mGrid.setContextMenuInfo(contextMenuInfo); return mGrid.showContextMenuForChild(mGrid); } /* * Update the fields of a TopSitesGridContextMenuInfo object * from a cursor. * * @param info context menu info object to be updated * @param cursor used to update the context menu info object */ private void updateContextMenuFromCursor(TopSitesGridContextMenuInfo info, Cursor cursor) { info.url = cursor.getString(cursor.getColumnIndexOrThrow(TopSites.URL)); info.title = cursor.getString(cursor.getColumnIndexOrThrow(TopSites.TITLE)); info.type = cursor.getInt(cursor.getColumnIndexOrThrow(TopSites.TYPE)); info.historyId = cursor.getInt(cursor.getColumnIndexOrThrow(TopSites.HISTORY_ID)); } }); registerForContextMenu(mList); registerForContextMenu(mGrid); }
From source file:com.example.mydemos.view.RingtonePickerActivity.java
private int addSilendStaticItem(ListView listView, int textResId) { silentView = getLayoutInflater().inflate(R.layout.tab_picker_item, listView, false); TextView textView = (TextView) silentView.findViewById(R.id.title); textView.setText(textResId);/*from ww w . j av a 2 s .c om*/ listView.addHeaderView(silentView, null, true); mStaticItemCount++; return listView.getHeaderViewsCount() - 1; }
From source file:com.example.mydemos.view.RingtonePickerActivity.java
private int addDefaultStaticItem(ListView listView, int textResId) { defaultView = getLayoutInflater().inflate(R.layout.tab_picker_item, listView, false); TextView textView = (TextView) defaultView.findViewById(R.id.title); textView.setText(textResId);/*from w w w. j a va 2 s. c om*/ listView.addHeaderView(defaultView, null, true); mStaticItemCount++; return listView.getHeaderViewsCount() - 1; }