List of usage examples for android.widget ListView getHeaderViewsCount
@Override public int getHeaderViewsCount()
From source file:com.csipsimple.ui.account.AccountsEditListFragment.java
@Override public void onListItemClick(ListView l, View v, int position, long id) { Log.d(THIS_FILE, "Checked " + position + " et " + id); ListView lv = getListView(); lv.setItemChecked(position, true);// w w w . ja va2 s. co m curCheckPosition = id; Cursor c = (Cursor) getListAdapter().getItem(position - lv.getHeaderViewsCount()); showDetails(id, c.getString(c.getColumnIndex(SipProfile.FIELD_WIZARD))); }
From source file:com.simas.vc.MainActivity.java
@Override public void onNavigationDrawerItemSelected(int position) { ListView lv = mNavDrawerFragment.getListView(); if (position == ListView.INVALID_POSITION || position < lv.getHeaderViewsCount() || position >= lv.getCount() - lv.getFooterViewsCount()) { // Skip headers and footers //noinspection UnnecessaryReturnStatement return;//from ww w .ja va2 s . c o m } else { // Check the item in the drawer lv.setItemChecked(position, true); Object checkedItem = lv.getItemAtPosition(lv.getCheckedItemPosition()); // Make sure the item is not already selected in the current EditorFragment if (lv.getChoiceMode() == ListView.CHOICE_MODE_SINGLE && getEditorFragment() != null && getEditorFragment().getItem() != checkedItem) { // Select item in pager int itemPosInPager = position - lv.getHeaderViewsCount() + 1; // +1 for empty item mViewPager.setCurrentItem(itemPosInPager); // Close drawer mNavDrawerFragment.setDrawerOpen(false); } } }
From source file:com.fututel.ui.account.AccountsEditListFragment.java
@Override public void onListItemClick(ListView l, View v, int position, long id) { Log.d(THIS_FILE, "Checked " + position + " et " + id); ListView lv = getListView(); lv.setItemChecked(position, true);//from w w w . j av a 2s . c o m curCheckPosition = id; Cursor c = (Cursor) getListAdapter().getItem(position - lv.getHeaderViewsCount()); showDetails(id, c.getString(c.getColumnIndex(SipProfile.FIELD_WIZARD))); }
From source file:org.mozilla.gecko.tests.AboutHomeTest.java
/** * Waits for the given ListView to have a non-empty adapter and be populated * with a minimum number of items.//from w w w .ja v a 2 s . c o m * * This method will return false if the given ListView or its adapter is null, * or if the ListView does not have the minimum number of items. */ protected boolean waitForListToLoad(final ListView listView, final int minSize) { Condition listWaitCondition = new Condition() { @Override public boolean isSatisfied() { if (listView == null) { return false; } final ListAdapter adapter = listView.getAdapter(); if (adapter == null) { return false; } return (listView.getCount() - listView.getHeaderViewsCount() >= minSize); } }; return waitForCondition(listWaitCondition, MAX_WAIT_MS); }
From source file:org.mariotaku.twidere.fragment.support.BaseStatusesListFragment.java
@Override public void onListItemClick(final ListView l, final View v, final int position, final long id) { final Object tag = v.getTag(); if (tag instanceof StatusViewHolder) { final int pos = position - l.getHeaderViewsCount(); final ParcelableStatus status = mAdapter.getStatus(pos); if (status == null) return; final AsyncTwitterWrapper twitter = getTwitterWrapper(); if (twitter != null) { TwitterWrapper.removeUnreadCounts(getActivity(), getTabPosition(), status.account_id, status.id); }// w w w . j a v a 2 s . c o m if (((StatusViewHolder) tag).show_as_gap) { final long since_id = position + 1 < mAdapter.getActualCount() ? mAdapter.getStatus(pos + 1).id : -1; getStatuses(new long[] { status.account_id }, new long[] { status.id }, new long[] { since_id }); mListView.setItemChecked(position, false); } else { if (mMultiSelectManager.isActive()) { setItemSelected(status, position, !mMultiSelectManager.isSelected(status)); return; } openStatus(getActivity(), status); } } }
From source file:de.vanita5.twittnuker.fragment.support.BaseStatusesListFragment.java
@Override public void onListItemClick(final ListView l, final View v, final int position, final long id) { final Object tag = v.getTag(); if (tag instanceof StatusViewHolder) { final int pos = position - l.getHeaderViewsCount(); final ParcelableStatus status = mAdapter.getStatus(pos); if (status == null) return; final AsyncTwitterWrapper twitter = getTwitterWrapper(); if (twitter != null) { TwitterWrapper.removeUnreadCounts(getActivity(), getTabPosition(), status.account_id, status.id); }/*from w ww . jav a 2 s . c om*/ if (((StatusViewHolder) tag).show_as_gap) { final long since_id = position + 1 < mAdapter.getActualCount() ? mAdapter.getStatus(pos + 1).id : -1; getStatuses(new long[] { status.account_id }, new long[] { status.id }, new long[] { since_id }); mListView.setItemChecked(position, false); } else { if (mMultiSelectManager.isActive()) { setItemSelected(status, position, !mMultiSelectManager.isSelected(status)); return; } openStatus(getActivity(), status.account_id, status.id); } } }
From source file:com.concentricsky.android.khanacademy.app.VideoListActivity.java
@Override protected void onStart() { Log.d(LOG_TAG, "onStart"); super.onStart(); stopped = false;/*from www .j ava2s. co m*/ mainMenuDelegate = new MainMenuDelegate(this); listView = (AbsListView) findViewById(android.R.id.list); listView.setOnItemClickListener(clickListener); if (listView instanceof ListView) { // It is important that this is inflated with listView passed as the parent, despite the attach false parameter. // Otherwise, the view ends up with incorrect LayoutParams and we see crazy, crazy behavior. headerView = getLayoutInflater().inflate(R.layout.header_video_list, listView, false); ListView lv = (ListView) listView; if (lv.getHeaderViewsCount() == 0) { lv.addHeaderView(headerView); } } else { // GridView, fixed header headerView = findViewById(R.id.header_video_list); } /** Responsive layout stuff * * Based on screen width, we will find either * narrow * a listview with a header view * items are a thumbnail to the left and a title on white space to the right. * header is a thumbnail with overlaid title across the bottom * * middle * a fixed header on top and a grid view below * header is thumb to left, title above scrolling description to right * items are thumbs with title overlaid across the bottom (3 across) * * wide * a fixed header to the left and a grid view on the right * header is thumb on top, title next, description at bottom * items are thumbs with title overlaid across the bottom (3 across) * * * So in this class, we * find view by id 'list' * if it's a ListView, inflate and attach header view * if not, then the header is fixed and already in the layout * either way, now we can find header views by id * adapter is the same either way * * * * **/ ActionBar ab = getActionBar(); displayOptionsAdapter = new ArrayAdapter<String>(getActionBar().getThemedContext(), android.R.layout.simple_list_item_1, displayOptions); ab.setDisplayHomeAsUpEnabled(true); ab.setTitle(""); ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); ab.setListNavigationCallbacks(displayOptionsAdapter, navListener); ab.setSelectedNavigationItem(isShowingDownloadedVideosOnly ? 1 : 0); requestDataService(new ObjectCallback<KADataService>() { @Override public void call(KADataService dataService) { VideoListActivity.this.dataService = dataService; if (topicId != null) { Dao<Topic, String> topicDao; try { topicDao = dataService.getHelper().getTopicDao(); topic = topicDao.queryForId(topicId); } catch (SQLException e) { e.printStackTrace(); } } else { Log.e(LOG_TAG, "Topic id not set for video list"); topic = dataService.getRootTopic(); topicId = topic.getId(); } thumbnailManager = dataService.getThumbnailManager(); api = dataService.getAPIAdapter(); api.registerUserUpdateListener(userUpdateListener); // This instead happens in ActionBar.OnNavigationListener#onNavigationItemSelected, which // fires after onResume. // setParentTopic(topic); } }); IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_LIBRARY_UPDATE); filter.addAction(ACTION_BADGE_EARNED); filter.addAction(ACTION_OFFLINE_VIDEO_SET_CHANGED); filter.addAction(ACTION_DOWNLOAD_PROGRESS_UPDATE); filter.addAction(ACTION_TOAST); LocalBroadcastManager.getInstance(this).registerReceiver(receiver, filter); thumbExecutor = Executors.newSingleThreadExecutor(); }
From source file:com.devpaul.filepickerlibrary.FilePickerActivity.java
@Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); if (l.getHeaderViewsCount() != 1) { //adjust for list view header view. position += 1;//ww w . j av a2s. c om } if (position > 0) { currentFile = files[position - 1]; } if (adapter.getSelectedPosition() == position) { hideButtons(); adapter.setSelectedPosition(-1); } else { adapter.setSelectedPosition(position - 1); showButtons(); } }
From source file:org.mariotaku.twidere.fragment.BaseStatusesListFragment.java
@Override public void onListItemClick(final ListView l, final View v, final int position, final long id) { mSelectedStatus = null;//from w w w.j a v a 2 s .com final Object tag = v.getTag(); if (tag instanceof StatusViewHolder) { final boolean click_to_open_menu = mPreferences.getBoolean(PREFERENCE_KEY_CLICK_TO_OPEN_MENU, false); final ParcelableStatus status = mSelectedStatus = mAdapter .getStatus(position - l.getHeaderViewsCount()); if (status == null) return; final StatusViewHolder holder = (StatusViewHolder) tag; if (holder.show_as_gap) { getStatuses(new long[] { status.account_id }, new long[] { status.status_id }, null); } else { if (mApplication.isMultiSelectActive()) { final NoDuplicatesLinkedList<Object> list = mApplication.getSelectedItems(); if (!list.contains(status)) { list.add(status); } else { list.remove(status); } return; } if (click_to_open_menu) { openMenu(v, status); } else { openStatus(getActivity(), status); } } } }
From source file:com.yeldi.yeldibazaar.AppDetails.java
@Override protected void onListItemClick(ListView l, View v, int position, long id) { curapk = app.apks.get(position - l.getHeaderViewsCount()); if (app.installedVerCode == curapk.vercode) removeApk(app.id);/* w ww. j a v a 2 s . co m*/ else if (app.installedVerCode > curapk.vercode) { AlertDialog.Builder ask_alrt = new AlertDialog.Builder(this); ask_alrt.setMessage(getString(R.string.installDowngrade)); ask_alrt.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { install(); } }); ask_alrt.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { return; } }); AlertDialog alert = ask_alrt.create(); alert.show(); } else install(); }