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
0
votes
1 answer

How to get rid of the resource not found exception when clicked on item view on recycler view and instead of data and activity lauch, it crashes app

I have built an app to learn the use of adapter and recycler view. It contains a recycler view and adapter, it uses data class to show data on clicked to an item of the recycler view, but the app crashes on runtime whenever I click on an item of…
0
votes
2 answers

android - Imageview has height 0 in adapter

I've an imageview in my RecyclerView's adapter ... I download the image for it with Glide library . this is item view code :
0
votes
1 answer

How to change Recyclerview background with click in Android

In my application I want used RecyclerView and I want when click on Items, change background. I want first show default item for selected and when user change this default item, change background and deselected this default item. My Code : class…
Dr.KeyOk
  • 608
  • 1
  • 6
  • 13
0
votes
1 answer

How to swap the selected recycler view item with the first item with change background color

here I change the background of the selected item position and set that item to the first position init override fun onBindViewHolder(holder: FeelingsViewHolder, position: Int) { val item = dataset[position] holder.title.text =…
0
votes
2 answers

CopytoClipboard not working in Adapter to show in recyclerview

I have a recyclerview with adapter (to show external strings)and I'm trying to click a button "copy" so that it copies the strings in view to the clipboard. CardLayout.xml Button to use as copy button is android:id="@+id/copyactivity"
0
votes
1 answer

Items in RecyclerView are different with ViewBinding

When i make Adapter in regular way, with findViewById it looks ok: like this, but when i do it with view binding looks like this 2 Adapter with ViewBinding: class HomePageFoldersAdapter() : RecyclerView.Adapter()…
0
votes
0 answers

select and unselect RecyclerView item without using checkbox or radio button or etc

Select and Unselect items in recyclerview without using any checkbox or radio button or etc. I want to select 1st recyclerview item on longclick and then all the other item on single click in recyclerview list. Unselect item on single click as well…
0
votes
1 answer

Kotlin Recyclerview change item color onClick

i have a Recyclerview adapter in Kotlin and when i click it change the color to Red but if i click another item, the previous item still have the Red color. How to make the logic when the item click it will change Red and when click another item it…
0
votes
1 answer

How to refer to the variable in adapter apart from RecyclerView.ViewHolder?

I have: public class RecyclerAdapter extends ListAdapter{ public TextView name_product1; public TextView category_product1; class RecyclerHolder extends RecyclerView.ViewHolder { public…
0
votes
1 answer

remove fragment in viewPager2 and FragmentStateAdapter is not working

I've 3 Fragment - F1, F2, and F3. I've attached them in a PagerAdaper (viewPager2). The initialization of the PagerAdapter in PagerFragment (in onCreateView) is - binding = PagerFargmentBinding.inflate(inflater, container, false) adapter =…
0
votes
1 answer

Attempt to invoke virtual method on a null object reference Android Adapter

I want to include a SearchView I have found onto my Android app, but I am facing an issue when setAdapter binds the adapter to the view: OnCreate from MainActivity: @Override protected void onCreate(Bundle savedInstanceState) { …
0
votes
1 answer

What superclass should I choose for my Adapter Class?

I am making a time table app. In that app, each row is a CardView that has three columns - index, task's name, total hours spent on that task. index is a TextView, task name and total hours spent are EditView. I want to transfer each row's data…
0
votes
1 answer

When clicking on Button on ListView item, the state of the last item changes

Hey so the goal is that when the button cancel of a list item is clicked, the state of the item must be shown as "Canceled" and the button goes black. However, when pressing on the button the button does go black but the list item doesn't change…
0
votes
1 answer

Fragment ListView doubles on return

I use a custom adapter for my ListView in a fragment. When I go to a second fragment and press the back key to go back, though, my list doubles (everything from my ArrayList is added again to the listView). This happens everytime I go to my second…
0
votes
0 answers

How to add onAttach in adapter in Android Studio?

I followed this video in order to create a reaction dialog but I get this error java.lang.ClassCastException: com.example.app.Activities.MainActivity@cbb7134 at…