Java Code Examples for android.widget.BaseAdapter
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project androidquery, under directory /src/com/androidquery/.
Source file: AbstractAQuery.java

/** * Notify a ListView that the data of it's adapter is changed. * @return self */ public T dataChanged(){ if (view instanceof AdapterView) { AdapterView<?> av=(AdapterView<?>)view; Adapter a=av.getAdapter(); if (a instanceof BaseAdapter) { BaseAdapter ba=(BaseAdapter)a; ba.notifyDataSetChanged(); } } return self(); }
Example 2
From project droidkit, under directory /src/org/droidkit/widget/.
Source file: SeparatedListAdapter.java

/** * {@inheritDoc} */ public Object getItem(int pos){ for ( Object section : mSections.keySet()) { BaseAdapter adapter=mSections.get(section); int size=adapter.getCount() + 1; if (pos == 0) { return section; } if (pos < size) { return adapter.getItem(pos - 1); } pos-=size; } return null; }
Example 3
From project GSM-Signal-Tracking-, under directory /gpstracker/src/nl/sogeti/android/gpstracker/viewer/.
Source file: SegmentOverlay.java

private boolean handleMediaTapList(List<Uri> tappedUri){ if (tappedUri.size() == 1) { return handleMedia(mLoggerMap,tappedUri.get(0)); } else { BaseAdapter adapter=new MediaAdapter(mLoggerMap,tappedUri); mLoggerMap.showDialog(adapter); return true; } }
Example 4
From project keepassdroid, under directory /src/com/keepassdroid/.
Source file: GroupBaseActivity.java

public void refreshIfDirty(){ Database db=App.getDB(); if (db.dirty.contains(mGroup)) { db.dirty.remove(mGroup); BaseAdapter adapter=(BaseAdapter)getListAdapter(); adapter.notifyDataSetChanged(); } }
Example 5
From project ohmagePhone, under directory /src/com/google/android/imageloader/.
Source file: ImageLoader.java

/** * {@inheritDoc} */ @Override public void send(String url,Bitmap bitmap,ImageError error){ BaseAdapter adapter=mAdapter.get(); if (adapter == null) { return; } if (!adapter.isEmpty()) { adapter.notifyDataSetChanged(); } else { } }
Example 6
From project android-flip, under directory /FlipView/Demo/src/com/aphidmobile/flip/demo/.
Source file: FlipButtonActivity.java

/** * Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setTitle(R.string.activity_title); flipView=new FlipViewController(this); flipView.setAdapter(new BaseAdapter(){ @Override public int getCount(){ return 10; } @Override public Object getItem( int position){ return position; } @Override public long getItemId( int position){ return position; } @Override public View getView( int position, View convertView, ViewGroup parent){ NumberButton button; if (convertView == null) { button=new NumberButton(parent.getContext(),position); button.setTextSize(360); } else { button=(NumberButton)convertView; button.setNumber(position); } return button; } } ); setContentView(flipView); }
Example 7
From project android-joedayz, under directory /Proyectos/GreenDroid/src/greendroid/widget/.
Source file: QuickActionGrid.java

@Override protected void populateQuickActions(final List<QuickAction> quickActions){ mGridView.setAdapter(new BaseAdapter(){ public View getView( int position, View view, ViewGroup parent){ TextView textView=(TextView)view; if (view == null) { final LayoutInflater inflater=LayoutInflater.from(getContext()); textView=(TextView)inflater.inflate(R.layout.gd_quick_action_grid_item,mGridView,false); } QuickAction quickAction=quickActions.get(position); textView.setText(quickAction.mTitle); textView.setCompoundDrawablesWithIntrinsicBounds(null,quickAction.mDrawable,null,null); return textView; } public long getItemId( int position){ return position; } public Object getItem( int position){ return null; } public int getCount(){ return quickActions.size(); } } ); mGridView.setOnItemClickListener(mInternalItemClickListener); }
Example 8
From project ChkBugReport, under directory /examples/testapp/src/com/sonymobile/chkbugreport/testapp/.
Source file: MainActivity.java

/** * Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); mListView=new ListView(this); mListView.setAdapter(new BaseAdapter(){ @Override public View getView( int position, View convertView, ViewGroup parent){ if (convertView == null) { LayoutInflater li=LayoutInflater.from(MainActivity.this); convertView=li.inflate(android.R.layout.simple_list_item_1,parent,false); } TextView tv=(TextView)convertView.findViewById(android.R.id.text1); Class<?> cls=TESTS[position]; tv.setText(cls.getSimpleName()); convertView.setTag(cls); return convertView; } @Override public long getItemId( int position){ return position; } @Override public Object getItem( int position){ return TESTS[position]; } @Override public int getCount(){ return TESTS.length; } } ); mListView.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick( AdapterView<?> parent, View view, int position, long id){ Class<?> cls=(Class<?>)view.getTag(); Intent intent=new Intent(MainActivity.this,cls); startActivity(intent); } } ); setContentView(mListView); }
Example 9
From project CineShowTime-Android, under directory /Libraries/GreenDroid/src/greendroid/widget/.
Source file: QuickActionGrid.java

@Override protected void populateQuickActions(final List<QuickAction> quickActions){ mGridView.setAdapter(new BaseAdapter(){ public View getView( int position, View view, ViewGroup parent){ TextView textView=(TextView)view; if (view == null) { final LayoutInflater inflater=LayoutInflater.from(getContext()); textView=(TextView)inflater.inflate(R.layout.gd_quick_action_grid_item,mGridView,false); } QuickAction quickAction=quickActions.get(position); textView.setText(quickAction.mTitle); textView.setCompoundDrawablesWithIntrinsicBounds(null,quickAction.mDrawable,null,null); return textView; } public long getItemId( int position){ return position; } public Object getItem( int position){ return null; } public int getCount(){ return quickActions.size(); } } ); mGridView.setOnItemClickListener(mInternalItemClickListener); }
Example 10
From project GreenDroid, under directory /GreenDroid/src/greendroid/widget/.
Source file: QuickActionGrid.java

@Override protected void populateQuickActions(final List<QuickAction> quickActions){ mGridView.setAdapter(new BaseAdapter(){ public View getView( int position, View view, ViewGroup parent){ TextView textView=(TextView)view; if (view == null) { final LayoutInflater inflater=LayoutInflater.from(getContext()); textView=(TextView)inflater.inflate(R.layout.gd_quick_action_grid_item,mGridView,false); } QuickAction quickAction=quickActions.get(position); textView.setText(quickAction.mTitle); textView.setCompoundDrawablesWithIntrinsicBounds(null,quickAction.mDrawable,null,null); return textView; } public long getItemId( int position){ return position; } public Object getItem( int position){ return null; } public int getCount(){ return quickActions.size(); } } ); mGridView.setOnItemClickListener(mInternalItemClickListener); }
Example 11
From project zirco-browser, under directory /src/org/greendroid/.
Source file: QuickActionGrid.java

@Override protected void populateQuickActions(final List<QuickAction> quickActions){ mGridView.setAdapter(new BaseAdapter(){ public View getView( int position, View view, ViewGroup parent){ TextView textView=(TextView)view; if (view == null) { final LayoutInflater inflater=LayoutInflater.from(getContext()); textView=(TextView)inflater.inflate(R.layout.gd_quick_action_grid_item,mGridView,false); } QuickAction quickAction=quickActions.get(position); textView.setText(quickAction.mTitle); textView.setCompoundDrawablesWithIntrinsicBounds(null,quickAction.mDrawable,null,null); return textView; } public long getItemId( int position){ return position; } public Object getItem( int position){ return null; } public int getCount(){ return quickActions.size(); } } ); mGridView.setOnItemClickListener(mInternalItemClickListener); }
Example 12
From project android-xbmcremote, under directory /src/org/xbmc/android/widget/.
Source file: FastScrollView.java

private void getSections(){ Adapter adapter=mList.getAdapter(); if (adapter instanceof HeaderViewListAdapter) { mListOffset=((HeaderViewListAdapter)adapter).getHeadersCount(); adapter=((HeaderViewListAdapter)adapter).getWrappedAdapter(); } if (adapter instanceof SectionIndexer) { mListAdapter=(BaseAdapter)adapter; mSections=((SectionIndexer)mListAdapter).getSections(); } }
Example 13
From project android_packages_apps_FileManager, under directory /src/org/openintents/filemanager/.
Source file: FileManagerActivity.java

private void toggleSelection(boolean selected){ for ( IconifiedText it : mDirectoryEntries) { it.setSelected(selected); } ((BaseAdapter)getListAdapter()).notifyDataSetChanged(); }
Example 14
From project apps-for-android, under directory /RingsExtended/src/com/example/android/rings_extended/.
Source file: FastScrollView.java

private void getSections(){ Adapter adapter=mList.getAdapter(); if (adapter instanceof HeaderViewListAdapter) { mListOffset=((HeaderViewListAdapter)adapter).getHeadersCount(); adapter=((HeaderViewListAdapter)adapter).getWrappedAdapter(); } if (adapter instanceof SectionIndexer) { mListAdapter=(BaseAdapter)adapter; mSections=((SectionIndexer)mListAdapter).getSections(); } }
Example 15
From project BombusLime, under directory /src/org/bombusim/lime/activity/.
Source file: LoggerActivity.java

private void updateLogSize(){ logListView.setVisibility(View.GONE); logSize=Lime.getInstance().getLog().getLogRecords().size(); ((BaseAdapter)logListView.getAdapter()).notifyDataSetChanged(); logListView.invalidate(); if (!disableAutoScroll) { logListView.setSelection(logSize - 1); } logListView.setVisibility(View.VISIBLE); }
Example 16
From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.
Source file: FastScroller.java

private void getSections(){ Adapter adapter=mList.getAdapter(); mSectionIndexerV1=null; mSectionIndexerV2=null; if (adapter instanceof HeaderViewListAdapter) { mListOffset=((HeaderViewListAdapter)adapter).getHeadersCount(); adapter=((HeaderViewListAdapter)adapter).getWrappedAdapter(); } if (mList instanceof ExpandableListView) { ExpandableListAdapter expAdapter=((ExpandableListView)mList).getExpandableListAdapter(); if (expAdapter instanceof SectionIndexer) { mSectionIndexerV1=(SectionIndexer)expAdapter; mListAdapter=(BaseAdapter)adapter; mSections=mSectionIndexerV1.getSections(); } else if (expAdapter instanceof SectionIndexerV2) { mSectionIndexerV2=(SectionIndexerV2)expAdapter; mListAdapter=(BaseAdapter)adapter; } } else { if (adapter instanceof SectionIndexer) { mListAdapter=(BaseAdapter)adapter; mSectionIndexerV1=(SectionIndexer)adapter; mSections=mSectionIndexerV1.getSections(); } else if (adapter instanceof SectionIndexerV2) { mListAdapter=(BaseAdapter)adapter; mSectionIndexerV2=(SectionIndexerV2)adapter; } else { mListAdapter=(BaseAdapter)adapter; mSections=new String[]{" "}; } } }
Example 17
From project Catroid-maven-playground, under directory /src/main/java/at/tugraz/ist/catroid/content/bricks/.
Source file: ChangeBrightnessBrick.java

public View getView(Context context,int brickId,BaseAdapter adapter){ view=View.inflate(context,R.layout.brick_change_brightness,null); EditText editX=(EditText)view.findViewById(R.id.brick_change_brightness_edit_text); editX.setText(String.valueOf(changeBrightness)); editX.setOnClickListener(this); return view; }
Example 18
From project dreamDroid, under directory /src/net/reichholf/dreamdroid/fragment/.
Source file: ServiceListFragment.java

public void loadNavRoot(){ String title=getString(R.string.services); getSherlockActivity().setTitle(title); mNavItems.clear(); String[] servicelist=getResources().getStringArray(R.array.servicelist); String[] servicerefs=getResources().getStringArray(R.array.servicerefs); for (int i=0; i < servicelist.length; i++) { ExtendedHashMap map=new ExtendedHashMap(); map.put(Event.KEY_SERVICE_NAME,servicelist[i]); map.put(Event.KEY_SERVICE_REFERENCE,servicerefs[i]); mNavItems.add(map); } mNavReference=SERVICE_REF_ROOT; mNavName=""; getSherlockActivity().invalidateOptionsMenu(); ((BaseAdapter)mNavList.getAdapter()).notifyDataSetChanged(); }
Example 19
From project Gaggle, under directory /src/com/geeksville/gaggle/.
Source file: ListWaypointsActivity.java

@Override protected BaseAdapter createListAdapter(){ String[] from=new String[]{LocationLogDbAdapter.KEY_NAME,LocationLogDbAdapter.KEY_DESCRIPTION,WaypointCursor.KEY_DIST_PILOTX,LocationLogDbAdapter.KEY_WAYPOINT_TYPE,WaypointCursor.KEY_DIST_PILOTY}; int[] to=new int[]{R.id.name,R.id.description,R.id.distance,R.id.image,R.id.units}; SimpleCursorAdapter a=new SimpleCursorAdapter(this,R.layout.waypoint_row,myCursor,from,to); final int distcol=myCursor.getColumnIndex(WaypointCursor.KEY_DIST_PILOTX); final int distycol=myCursor.getColumnIndex(WaypointCursor.KEY_DIST_PILOTY); final int typecol=myCursor.getColumnIndex(LocationLogDbAdapter.KEY_WAYPOINT_TYPE); a.setViewBinder(new SimpleCursorAdapter.ViewBinder(){ public boolean setViewValue( View _view, Cursor cursor, int columnIndex){ try { if (columnIndex == distcol) { TextView view=(TextView)_view; int dist=cursor.getInt(distcol); String distStr=(dist == -1) ? "---" : Units.instance.metersToDistance(dist); view.setText(distStr); return true; } if (columnIndex == distycol) { TextView view=(TextView)_view; view.setText(Units.instance.getDistanceUnits()); return true; } if (columnIndex == typecol) { ImageView view=(ImageView)_view; ExtendedWaypoint w=((WaypointCursor)cursor).getWaypoint(); view.setImageDrawable(w.getIcon()); return true; } } catch ( RuntimeException ex) { Log.d("ListWaypoint","Caught exception building waypoint list: " + ex.getMessage()); } return false; } } ); return a; }
Example 20
From project iPhoroidUI, under directory /src/org/klab/iphoroid/widget/support/.
Source file: HasImage.java

public void onScrollStateChanged(AdapterView<?> view,int scrollState){ Log.i("HasImage.AdapterViewOnScrollListener","onScrollStateChanged.1: " + this.scrollState + ", "+ scrollState); if (scrollState == SCROLL_STATE_IDLE) { ((BaseAdapter)view.getAdapter()).notifyDataSetChanged(); Util.recycleImages(view); } else if (scrollState == SCROLL_STATE_TOUCH_SCROLL) { ((BaseAdapter)view.getAdapter()).notifyDataSetChanged(); } this.scrollState=scrollState; Log.i("HasImage.AdapterViewOnScrollListener","onScrollStateChanged.2: " + scrollState); }
Example 21
From project Juggernaut_SystemUI, under directory /src/com/android/systemui/widget/.
Source file: PageView.java

public void setAdapter(BaseAdapter adapter,final int startPosition){ mAdapter=adapter; if (mAdapter != null) { mCurrentPage=startPosition; fillCarousel(startPosition); post(new Runnable(){ public void run(){ if (!mCarouselMode && startPosition == 0) { PageView.super.scrollToPage(0); } else if (!mCarouselMode && startPosition == mAdapter.getCount() - 1) { PageView.super.scrollToPage(2); } else { PageView.super.scrollToPage(1); } } } ); if (mAdapter.getCount() <= 1) { setBounceEnabled(true); } } }
Example 22
From project platform_packages_apps_browser, under directory /src/com/android/browser/.
Source file: NavTabScroller.java

protected void setAdapter(BaseAdapter adapter,int selection){ mAdapter=adapter; mAdapter.registerDataSetObserver(new DataSetObserver(){ @Override public void onChanged(){ super.onChanged(); handleDataChanged(); } @Override public void onInvalidated(){ super.onInvalidated(); } } ); handleDataChanged(selection); }
Example 23
From project PocketVDC, under directory /src/sate/pocketvdc/activities/.
Source file: ManageGridActivity.java

@Override protected void onActivityResult(int requestCode,int resultCode,Intent intent){ if ((resultCode == Activity.RESULT_OK) && (requestCode == DATA_FROM_EDIT_ACTIVITY)) { Bundle getIt=intent.getExtras(); Grid returnedGridObject=getIt.getParcelable(GET_BACK_OBJECT); if (this.selectedGrid != null) { this.grids.remove(this.selectedGrid); } this.grids.add(returnedGridObject); ((BaseAdapter)listView.getAdapter()).notifyDataSetChanged(); Grid.writeGrids(this.grids,this); } else if ((resultCode == Activity.RESULT_CANCELED) && (requestCode == RETURN_TO_WINDOW)) { this.setVisible(true); return; } if (resultCode == Activity.RESULT_OK && requestCode == DATA_FROM_ADD_ACTIVITY) { Bundle getAddGrid=intent.getExtras(); Grid newAddedGrid=getAddGrid.getParcelable(ADDED_A_GRID); this.grids.add(newAddedGrid); ((BaseAdapter)listView.getAdapter()).notifyDataSetChanged(); Grid.writeGrids(this.grids,this); } }
Example 24
From project sthlmtraveling, under directory /src/com/markupartist/sthlmtraveling/.
Source file: MultipleListAdapter.java

/** * Get the adaper id present at the specifed position. <p> Note. Pass the position that is relative to the current adapter. This is important if used with nested adapters. * @param position The position. * @return The adapter id. */ public int getAdapterId(int position){ for ( Entry<Integer,BaseAdapter> e : mAdapters.entrySet()) { if (position == 0) return e.getKey(); int size=e.getValue().getCount(); if (position < size) return e.getKey(); position-=size; } return -1; }
Example 25
From project SWE12-Drone, under directory /catroid/src/at/tugraz/ist/catroid/content/bricks/.
Source file: ChangeBrightnessBrick.java

public View getView(Context context,int brickId,BaseAdapter adapter){ view=View.inflate(context,R.layout.brick_change_brightness,null); EditText editX=(EditText)view.findViewById(R.id.brick_change_brightness_edit_text); editX.setText(String.valueOf(changeBrightness)); editX.setOnClickListener(this); return view; }
Example 26
From project TransportsRennes, under directory /TransportsBordeaux/src/fr/ybo/transportsbordeaux/activity/bus/.
Source file: ListNotif.java

@Override public boolean onContextItemSelected(MenuItem item){ AdapterView.AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)item.getMenuInfo(); switch (item.getItemId()) { case R.id.supprimerNotif: Notification notification=(Notification)getListAdapter().getItem(info.position); TransportsBordeauxApplication.getDataBaseHelper().delete(notification); ((NotifAdapter)getListAdapter()).getNotifications().clear(); ((NotifAdapter)getListAdapter()).getNotifications().addAll(TransportsBordeauxApplication.getDataBaseHelper().selectAll(Notification.class)); ((BaseAdapter)getListAdapter()).notifyDataSetChanged(); return true; default : return super.onContextItemSelected(item); } }