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
9
votes
4 answers

OnBackpressed get empty view on tablayout

I am stuck in solving this problem. I have set tabs in fragment using TabLayout and ViewPager. The problem is when i move to next fragment and then i press back button i get empty tabs view. Here I am attaching my code: home.xml
9
votes
3 answers

How to recycleview adapter under another recycleview adapter?

I have a RecyclerView. It has a custom layout and inside the custom layout is another RecyclerView. When I notify the recycler view that an item has been deleted, my main recycler view is updated but my custom view recycle view is not getting…
9
votes
3 answers

Why do I not need to use Adapter.notifyDataSetChanged()?

the contactsList is empty until the readContacts()method was executed, in other words, when contactsView.setAdapter(adapter) was executed, the contactsList is empty, so why this code still can show contacts' info correctly? public class MainActivity…
9
votes
1 answer

Calling Custom ListView Adapter from Fragment Class Main Activity

I've written a few listView activities, as a proof of concept for myself that I could do it. Now, I'm having trouble loading a listView activity into a single tab for an app with multiple tabs, that allows both swiping and tab selection for…
9
votes
4 answers

Android: visible ListView images flicker when adding data to ArrayAdapter

I have a custom adapter which extends ArrayAdapter, it implements the view holder patterns to show data (text + image) from a web service. for lazy loading of the images I use the async tasks pattern from the advanced training in the Android's…
8
votes
4 answers

Unable to use LayoutInflater in custom adapter

I'm looking into writing a custom adapter to populate a listview with 3 textviews per line. I've found quite a bit of example code to do this, but the one that seemed the best was at: http://www.anddev.org/custom_widget_adapters-t1796.html After a…
Teknogrebo
  • 1,247
  • 1
  • 12
  • 22
8
votes
2 answers

Why notifyItemChanged only works in post Runnable after setAdapter?

public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); RecyclerView list = (RecyclerView)…
WenChao
  • 3,586
  • 6
  • 32
  • 46
8
votes
2 answers

RecyclerView getAdapterPosition() returns -1 on a callback so I can't show the new appearance for the item

Each item on my RecyclerView has a button that has three states: OPEN, LOADING, and CLOSED. Initially all the buttons are in the OPEN state. When a button is clicked, the state is changed to LOADING and a network call is performed in the background.…
Randy Sugianto 'Yuku'
  • 71,383
  • 57
  • 178
  • 228
8
votes
4 answers

android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams

Following numerous tutorials and example projects I've arrived at the following code which should fill a ListView with rows that contain multiple values out of a Line object. Being a newbie programmer I cannot for the life of me figure out where…
Hetiwos
  • 229
  • 1
  • 4
  • 13
8
votes
2 answers

android how to call startActivityForResult inside an adapter

I have an adapter class : public class AdapterAllAddress extends BaseExpandableListAdapter { private Context context; public AdapterAllAddress(Context context, ArrayList groups) { // TODO Auto-generated…
8
votes
3 answers

How to force redraw of listview?

This question is a little different from others of a similar title. I am not trying to update the data in the list, I am trying to update the look of the list. My app is fragment based using the support library. I have a PreferenceActivity where I…
Barak
  • 16,318
  • 9
  • 52
  • 84
8
votes
2 answers

Image GridView Inside Fragment

I have just started to develop on the android platform after developing on iOS. I have looked around and I can't seem to figure it out. I am trying to have a grid view appear after a tab in the action bar is selected. The fragment is brought into…
StuStirling
  • 15,601
  • 23
  • 93
  • 150
7
votes
3 answers

How to reset the ListView with the ArrayAdapter after fetching data

I am using an ListAdapter to populate a ListView like this: static final String[] PROBLEMS = new String[] {"one", "two", "three" }; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { …
GeekedOut
  • 16,905
  • 37
  • 107
  • 185
7
votes
2 answers

PagedListAdapter Not Using DiffUtil On invalidate Data

Every time I call invalidate data my DIFF_UTIL is not used. The logs are not shown and the entire list is updated with new data causing the screen to move positions etc. Not sure what the issue is here. I have PagedListAdapter with a…
MobDev
  • 1,219
  • 1
  • 12
  • 25
7
votes
1 answer

RecyclerView ListAdapter does not update list correctly

I'm using Android Room and Rx Flowable to update a RecyclerView will the object from my database. For better animation and performance, I updated the project to use the new ListAdapter in my project. The problem is when user presses a Checkbox the…