Questions tagged [android-adapter]

An Adapter object acts as a bridge between an AdapterView and the underlying data for that view.

An Adapter represents the connection between a View with some kind of data source. Adapters generally come in two flavors: those that represent array/list based data and those that represent Cursor based data.

  • The Adapter provides access to the data items.
  • The Adapter is also responsible for making a View for each item in the data set.

See Adapter reference for more information.

Tag Usage:

3159 questions
20
votes
1 answer

android notifyItemRangeInserted disable autoscroll

I'm using RecyclerView as the base for my data list. i've implemented custom RecyclerView.Adapter which is based on ArraList. on fetching data from the internet the code that i'm running is: public void addItems(List items){ final int…
royB
  • 11,685
  • 14
  • 48
  • 77
18
votes
11 answers

Fast taps (clicks) on RecyclerView opens multiple Fragments

I have implemented onClick listener to my ViewHolder for my RecyclerView But when I perform very fast double taps or mouse clicks, it performs the task (opens a seperate fragment in this case) twice or three times. here is my code public class…
17
votes
3 answers

PagedListAdapter jumps to beginning of the list on receiving new PagedList

I'm using Paging Library to load data from network using ItemKeyedDataSource. After fetching items user can edit them, this updates are done inside in Memory cache (no database like Room is used). Now since the PagedList itself cannot be updated…
17
votes
4 answers

Make last Item / ViewHolder in RecyclerView fill rest of the screen or have a min height

I'm struggeling with the RecyclerView. I use a recycler view to display the details of my model class. //My model class MyModel { String name; Double latitude; Double longitude; Boolean isOnline; ... } Since some of the values…
xxtesaxx
  • 5,150
  • 2
  • 26
  • 42
17
votes
1 answer

Bluetooth device discovery in Android -- startDiscovery()

Goal: Build an Android app that discovers the names and addresses of BT devices within range and submits their values to a webservice. BT devices have not been previously bonded to the host device, I just want to poll everything as I walk…
16
votes
2 answers

Listview not getting populated, getView() isn't getting called

I'm having a few problems getting my listview to show up in a simple application i'm writing. For some reason the getView() method of my adapter class isn't getting called. However, when when getCount() is called in my adapter class it isn't…
slayton
  • 19,732
  • 8
  • 57
  • 86
15
votes
6 answers

Using AsyncTask to load Images in ListView

I have one ListView which can hold an image. It depends if image exists or not in SDCARD. Here my example code: public class MainActivity extends Activity { ListView mListView; @Override protected void onCreate(Bundle…
Rodrigo
  • 5,104
  • 5
  • 37
  • 72
15
votes
2 answers

CursorAdapter bindView optimization

When overriding ArrayAdapter I know is correct using a pattern like this: if(view != null){ ...create new view setting fields from data }else return view; //reuse view is correct too using this pattern with CursorAdapters? My problem is that…
user1610075
  • 1,483
  • 3
  • 15
  • 31
15
votes
1 answer

Insert pages in the middle of a FragmentPageAdapter

I'm using a ViewPager from ViewPageIndicator and I need to be able to dynamically insert one fragment in the middle of others. I've tried to manage the model with FragmentPagerAdapter and FragmentStatePagerAdapter (both from v4 support code) and the…
lujop
  • 12,544
  • 9
  • 55
  • 90
14
votes
1 answer

Is it possible to bind a TableLayout with a ArrayAdapter?

Is it possible to bind a TableLayout with a ArrayAdapter?
Manish Khot
  • 2,957
  • 1
  • 25
  • 37
14
votes
2 answers

Are android adapters an example of Adapter Design pattern?

Do Android adapters use Adapter Design pattern? The GoF design patterns book describes Adapter Design Pattern as The Adapter Pattern converts the interface of a class into another interface the clients expect. Adapter lets classes work…
uptoNoGood
  • 518
  • 3
  • 19
14
votes
3 answers

RecyclerView: find last visible item immediately after view created

I'm having a problem with the following methods: int firstVisibleItemPosition = gridLayoutManager.findFirstVisibleItemPosition(); int lastVisibleItemPosition = gridLayoutManager.findLastVisibleItemPosition(); My goal: save analytic data about what…
Tal Kanel
  • 9,855
  • 10
  • 55
  • 93
13
votes
4 answers

Add item to ListView without reloading

I'm wondering if there's a way to add an item to the ListView without causing the reload of the whole list. I have a BaseAdapter-derived ListView adapter, and when the underlying model gets a new element added, it calls notifyDataSetChanged(), which…
SVD
  • 4,673
  • 2
  • 24
  • 38
13
votes
3 answers

How to set Layoutparams height/width in dp value?

I tried setting height/width manually in button but it didn't work. Then implemented Layoutparams. But size shows small and not getting required dp value. XML
13
votes
3 answers

How to use ButterKnife inside adapter

I would like to use ButterKnife to bind my views inside listView adpater. I tried this, but i can not simply use my "spinner" var. public class WarmSpinnerAdapter extends ArrayAdapter { Context context; public…
Stepan
  • 797
  • 2
  • 20
  • 30