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 flavours: those representing 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:

3394 questions
38
votes
9 answers

Android: how to refresh ListView contents?

My ListView is using an extension of BaseAdapter, I can not get it to refresh properly. When I refresh, it appears that the old data draws on top of the new data, until a scroll event happens. The old rows draw on top of the new rows, but the old…
ab11
  • 19,770
  • 42
  • 120
  • 207
35
votes
2 answers

How to add section separators / dividers to a ListView?

I'm currently making a menu for my app, using a DrawerLayout and an ArrayAdapter subclass to achieve something looking like Facebook's drawer menu. I currently have no problems creating the list, but now that it looks good, i'd like to add…
Jivay
  • 1,034
  • 3
  • 10
  • 23
34
votes
4 answers

RecyclerView.Adapter.notifyItemChanged() never passes payload to onBindViewHolder()

I'm trying to update a ViewHolder in a RecyclerView without rebinding the entire thing. According to the docs, I should do this by calling RecyclerView.Adapter.notifyItemChanged(int position, Object payload), where payload is an arbitrary object…
33
votes
6 answers

How to properly handle screen rotation with a ViewPager and nested fragments?

I've got this activity, which holds a fragment. This fragment layout consists of a view pager with several fragments (two, actually). When the view pager is created, its adapter is created, getItem gets called and my sub fragments are created.…
Benoit Duffez
  • 11,839
  • 12
  • 77
  • 125
32
votes
8 answers

RecyclerView Adapter notifyDataSetChanged not working

I extended RecyclerView.Adapter And when I called: mRecyclerView.getAdapter().notifyDataSetChanged(); Nothing happened. The only way to refresh the view is to set again the adapter (see this…
David
  • 37,109
  • 32
  • 120
  • 141
32
votes
3 answers

Using Android AutoCompleteTextView with ArrayAdapter instead of ArrayAdapter

I wanted to use AutoCompleteTextView in my android application.I know how to use it with simple array of Strings, but I wanted AutoCompleteTextView to use list of Objects to perform completion.My code for this is following: ACTIVITY CODE public…
Anshul
  • 7,914
  • 12
  • 42
  • 65
31
votes
3 answers

How do I access to ListView from the adapter

I have a custom ListView with my own adapter. I'm handling the click on a Button in my ListView's item, and I want the ListView to become invisible on this click. I have no idea how to get access to the ListView from the adapter. public class…
user1049280
  • 5,176
  • 8
  • 35
  • 52
29
votes
2 answers

RecyclerView.ViewHolder unable to bind view with ButterKnife

I'm using ButterKnife to bind my views on my ViewHolder. My code is below: public class MyAdapter extends RecyclerView.Adapter { private List data; public MyAdapter(List data) { …
KVISH
  • 12,923
  • 17
  • 86
  • 162
28
votes
3 answers

Use custom View in a RecyclerView Adapter?

I have a basic custom View which looks like this: public class CustomView extends RelativeLayout { private User user; private ImageView profilePicture; public CustomView(Context context) { super(context); init(); …
28
votes
6 answers

Does notifydatasetchanged call onCreateViewHolder when using RecyclerView

I want to use a toggle to toggle between two different views but using the same RecyclerView. Basically, once you toggle, I want the RecyclerView adapter to recall onCreateViewHolder() but this time it will use a different layout item file. Does…
27
votes
2 answers

RecyclerView onBindViewHolder only called when getItemViewType changes

I have a viewholder with multiple viewtypes. When scrolling onBindViewHolder is only called when getItemViewType changes value. This causes my list items to not be updated properly. Is this a bug? Or I'm i doing something wrong here. This seems very…
26
votes
3 answers

ListView or TableLayout?

I am really confused now as to which one to learn. I am an iPhone app developer and now learning Android development. I have learnt how to use a ListView with a static array of strings using an Adapter. I am used to using custom cells in iPhone,…
24
votes
1 answer

Android Data Binding : Observable List to RecyclerView's Adapter

Is their a way, by using the ObservableList class from the new Data Binding library and the MVVM pattern, to avoid using "notifyItem(s)..." methods from the Adapter class? Or if not what could be the simpliest way to bind an ObservableList to a…
MHogge
  • 5,408
  • 15
  • 61
  • 104
24
votes
2 answers

Android: Radio button in custom list view

I am developing an application in which I need to implement radio buttons in list view. I want to implement a list view having one radio button and two text views in each row. And one button "Ok" below listview. What I have done is created a list…
23
votes
4 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