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
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
  • 3,027
  • 2
  • 29
  • 37
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
  • 10,475
  • 10
  • 60
  • 98
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,743
  • 2
  • 26
  • 38
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
  • 1,041
  • 5
  • 23
  • 35
13
votes
4 answers

RecyclerView.Adapter onBindViewHolder() gets wrong position

I'll show the code and after the steps to get the problem. I have a recyclerview inside a tabbed fragment that takes the dataset from a custom object: mRecyclerView = (RecyclerView)…
Informatheus
  • 1,025
  • 1
  • 9
  • 20
13
votes
2 answers

Dynamically remove an item from a ViewPager with FragmentStatePagerAdapter

There are quite a few discussions around this topic ViewPager PagerAdapter not updating the View Update ViewPager dynamically? Removing fragments from FragmentStatePagerAdapter I have tried various solutions (including the invalidation with…
Orkun
  • 6,998
  • 8
  • 56
  • 103
13
votes
3 answers

What is the working of setTag and getTag in ViewHolder pattern?

I have a simple code snippet for implementing custom listview. My code is as follows: WeatherAdapter.java : public class WeatherAdapter extends ArrayAdapter{ Context mcontext; int mlayoutResourceId; weather mdata[] = null; …
xyz
  • 1,325
  • 5
  • 26
  • 50
13
votes
1 answer

Dynamically skip pages in ViewPager

I got a ViewPager which holds Fragments via FragmentStatePagerAdapter. Let's say the pager initially holds the following pages (Fragments): A - B - C - D When the user swipes, he can move from A to B, B to C etc. But there are cases when the user…
13
votes
2 answers

Custom list items not responding to state_checked in selector

I'm going to begin by saying that I have read in detail almost every question on SO that I can find related to custom checkable list items and selectors. Many of them have similar issues, but none of the answers solve my problem. At a point in my…
Groppe
  • 3,819
  • 12
  • 44
  • 68
12
votes
1 answer

Android's ArrayAdapter - add strings listview instead of replace

This is how I add an array to listview: ListView my_listview = (ListView)findViewById(R.id.listView1); ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1,…
Badr Hari
  • 8,114
  • 18
  • 67
  • 100
12
votes
1 answer

Android recyclerview adapter with multiple viewtype using databinding

Is it possible to create a multiple view type in my adapter.. like adding a view for my header then below the header is a list. code snippet of my adapter : public class StoreAdapter extends RecyclerView.Adapter { …
12
votes
2 answers

Don't recycle specific view type in RecyclerView

I have a recycler view which is reusing view, my problem is that one viewholder contains a ViewPager and, if the recyclerview's adapter reuse the view where the viewholder is inflated then an exception occurs on the viewpager. However, the…
FVod
  • 2,245
  • 5
  • 25
  • 52
12
votes
2 answers

How to display an ArrayList in a RecyclerView?

I need to add an Activity where I can list the elements of an ArrayList and I've seen there's a newer and better way to display lists - RecyclerView. My question is how to implement this into my app. I've found that I need to use an…
FET
  • 942
  • 4
  • 13
  • 35
12
votes
2 answers

get fragment by tag or id from tablayout ,android

i use this tutorial for creating tab. and now i have a recyclerview in each fragment and i want to notify them from mainactivity. how to access the adapter in fragment? i use this for calling refreshData() method in fragment: TabFragment1…
javadroid
  • 1,421
  • 2
  • 19
  • 43
12
votes
8 answers

Popup Menu in custom ListView

What I want to achieve: I have a custom ListView adapter. To each Listitem I want to add a popup menu, pretty similar to the ListView in the current Google Play application. This is what I tried: Most of my code comes from this Android sample…
Al0x
  • 917
  • 2
  • 13
  • 30