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
13
votes
3 answers

How to set two adapters to one RecyclerView?

I am developing an android app in which I'm storing two different types of information on 'FirebaseDatabase`. Then in the MainActivity, I'm retrieving them and showing to users in a RecyclerView. Both information are meant to be shown in different…
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 Ozen
  • 6,343
  • 7
  • 46
  • 82
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,273
  • 5
  • 23
  • 44
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,464
  • 9
  • 39
  • 62
12
votes
3 answers

Fragment no longer exists for key FragmentStateAdapter with Viewpager2

I am using ViewPager2 for my project. I need to use nested fragments inside a fragment with viewpager2. it works like charm until I try to navigate between fragments(not nested ones). After the first time navigating between fragments, the…
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
  • 7,255
  • 17
  • 60
  • 97
12
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
  • 975
  • 1
  • 7
  • 19
12
votes
1 answer

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,355
  • 1
  • 15
  • 39
12
votes
6 answers

RecyclerView.Adapter.notifyItemMoved(0,1) scrolls screen

I have a RecyclerView managed by a LinearlayoutManager, if I swap item 1 with 0 and then call mAdapter.notifyItemMoved(0,1), the moving animation causes the screen to scroll. How can I prevent it?
Ari
  • 2,880
  • 1
  • 16
  • 26
12
votes
7 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
  • 1,090
  • 2
  • 12
  • 26
12
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…
12
votes
5 answers

Custom adapter getview is not called

I have a Custom adapter with a ListFragment but the adapters getView() is not getting called at all. This is how the adapter looks like - public class ModuleListItemAdapter extends BaseAdapter { List list; Context context; …
Akilan
  • 852
  • 1
  • 6
  • 19
12
votes
5 answers

How to use Universal Image Loader

I have a requirement where I need to load thumbnails and a Text in ListView which gets set by the custom Adapter. The Thumbnails should be stored in a cache memory, for that I am using the Universal Image Loader however I am pretty much confused in…
12
votes
3 answers

Can't set OnCheckedChangeListener to a Checkbox

I am trying to set a OnCheckedChangeListener to a CheckBox but my application exits in the run time. I also tried to set listeners for my TextView and I still get the same result. Can anyone help? import android.app.ListActivity; import…
Traveling Salesman
  • 1,901
  • 8
  • 36
  • 66
11
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
  • 842
  • 3
  • 9
  • 31