List of usage examples for android.widget Adapter getCount
int getCount();
From source file:Main.java
public static final int getAdapterPositionById(final Adapter adapter, final long id) throws NoSuchElementException { final int count = adapter.getCount(); for (int pos = 0; pos < count; pos++) { if (id == adapter.getItemId(pos)) { return pos; }//www . j a v a 2 s. com } throw new NoSuchElementException(); }
From source file:Main.java
/** * * @param adapter - adapter with objects to be searched * @param object - object to search in adapter * @param defaultPosition - default position to return if object is not in adapter * @return position of item or default position if item is not in adapter *///from w ww .j a v a 2s . com public static int getItemPosition(Adapter adapter, Object object, int defaultPosition) { int position = defaultPosition; for (int i = 0; i < adapter.getCount(); i++) { if (adapter.getItem(i).equals(object)) { position = i; break; } } return position; }
From source file:com.optimusinfo.elasticpath.cortex.common.Utils.java
@SuppressWarnings("rawtypes") public static int getTotalHeightofListView(AdapterView argAdapterView) { Adapter mAdapter = argAdapterView.getAdapter(); if (mAdapter == null) { // pre-condition return 0; }//from w w w . ja va 2 s .com int totalHeight = 0; for (int i = 0; i < mAdapter.getCount(); i++) { View mView = mAdapter.getView(i, null, argAdapterView); mView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); mView.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); totalHeight += mView.getMeasuredHeight(); } return totalHeight; }
From source file:com.lillicoder.demo.carouselview.widget.CarouselView.java
/** * Sets the {@link Adapter} for this view. * @param adapter Adapter to set./*from ww w. j a va2s . c om*/ */ public void setAdapter(Adapter adapter) { addIndicators(adapter.getCount()); mViewPager.setAdapter(adapter); }
From source file:co.edu.uniajc.vtf.content.SettingsFragment.java
public int getAdapterPositionById(Adapter adapter, final long id) throws NoSuchElementException { final int count = adapter.getCount(); for (int pos = 0; pos < count; pos++) { if (id == adapter.getItemId(pos)) { int liPosition = pos; return liPosition; }/* w ww . j a v a 2 s . co m*/ } return 0; }
From source file:com.github.nitrico.mapviewpager.MapViewPager.java
private void populateSingle(Adapter adapter) { map.clear();//from ww w . ja v a 2 s . com markers = new LinkedList<>(); for (int i = 0; i < adapter.getCount(); i++) { CameraPosition cp = adapter.getCameraPosition(i); if (cp != null) { MarkerOptions mo = createMarkerOptions(cp, adapter.getPageTitle(i).toString()); markers.add(map.addMarker(mo)); } else markers.add(null); } map.setOnMarkerClickListener(createMarkerClickListenerSingle(adapter)); initDefaultPosition(); }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.widget.ListWidgetConfig.java
private int getListPositionOf(final Adapter adapter, final long id) { if (adapter == null || adapter.getCount() == 0) return 0; int pos = 0;/*www . ja va 2s . c o m*/ for (int i = 0; i < adapter.getCount(); i++) { if (adapter.getItemId(i) == id) { pos = i; break; } } return pos; }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.widget.ListWidgetConfig.java
private int getSpinnerPositionOf(final Adapter adapter, final String entry) { if (adapter == null || adapter.getCount() == 0) return 0; int pos = 0;// ww w. j a v a 2 s .c o m for (int i = 0; i < adapter.getCount(); i++) { if (adapter.getItem(i).toString().equals(entry)) { pos = i; break; } } return pos; }
From source file:com.github.nitrico.mapviewpager.MapViewPager.java
private GoogleMap.OnMarkerClickListener createMarkerClickListenerSingle(final Adapter adapter) { return new GoogleMap.OnMarkerClickListener() { @Override//from ww w . ja v a2 s . c o m public boolean onMarkerClick(Marker marker) { for (int i = 0; i < adapter.getCount(); i++) { CameraPosition cp = adapter.getCameraPosition(i); if (cp != null && cp.target != null && cp.target.latitude == marker.getPosition().latitude && cp.target.longitude == marker.getPosition().longitude) { viewPager.setCurrentItem(i); marker.showInfoWindow(); return true; } } return false; } }; }