Switching between using multiple adapters for a single recyclerview - android

Can I utilize multiple adapters for my recyclerview wherein I can switch between using one of them to populate my recyclerview?
That is given adapter A populating my recyclerview,I can stop it and use adapter B to repopulate the recyclerview.

Yes.
Just use RecyclerView.setAdapter(adapter) with the new adapter

Related

Using multiple RecyclerView's adapters

Is it possible when we have more than one recycler view adapter in one project?
Each adapter is assigned to 1 activity
You can bind one adapter to one RecyclerView and even change it later. It doesn't matter how many RecyclerView's and adapters you have.

Setting more than one adapter for a single list view

Is it possible for setting more than one adapter to a single list?
For example
list.setAdapter(adapter1);
list.setAdapter(adapter2);
Maybe you can try attaching multiple adapters to a single adapter like here
android attaching multiple adapters to one adapter
Or maybe this
http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android-09/
if I understand what you need it for correctly
Pls update why you want it for so we have a better understanding

Using the Adapter Class to synchronize data with a non-AdapterView View Group

I would like to use an adapter to synchronize a List of data with a vertical LinearLayout where it will be displayed. The problem I'm having is that non-AdapterView View Groups (Like LinearLayout) do not have the setAdapter() method. Can anyone suggest a way of achieving this?
Instead use a ListView with SimpleAdapter or SimpleCursorAdapter. Both adapters are very flexible for all kinds of customization based on your data.

How can I bind table-layout with array-list in android?

Is there any way to bind a table-layout to array list in android, and how?
I mean like in C# that you type: table.datasource = list;
Instead of Table-layout, why don't you use listview? In listview, you can easily bind the data adapter to the listview.
I suggest if you can use ListView for your requirement then use it, its easy to implement as compared to TableLayout.
To set adapter inside the ListView, you just need to call:
listview.setAdapter(adapter);

How to reuse one custom listview activity in another activity?

Can I use my existing ListView as a sub-view in another view.
eg. I have a custom view, players list, I have implemented with a ListActivity and ArrayAdapter and is working fine.
Now I want a way to get this listview as View object so that I can add this view object as a child to another view.
I am thinking like, to build entire listview: my ListActivity is calling the ArrayAdapter iteratively by passing ArrayList item each time to build a list item view.
If I am correct, I need a way to call the same ArrayAdapter and need to prepare a ListView Object, right?
Can anybody plz help me.
Thanks in advance.
vpapana
The ListView and the Adapter are two different things:
The data is somewhere (in an array or if you need to be able to add/remove items, in an ArrayList)
The Adapter contains the data
The ListView displays it.
So:
Construct your empty ArrayList
Construct your adapter based on your ArrayList
Construct your ListView based on the Adapter
Then:
Each time you need to change the data, update the ArrayList
Call Adapter.notifyDataSetChanged()
Watch your list being automatically updated :)
To add your list to a tablelayout, see the API documentation, SDK tutorial and this tutorial which has a specific section on how to add rows programmatically.

Categories

Resources