Reputation: 1
I have a listview connected to an adapter showing messages but, I am trying to implement next and previous buttons in a different activity.
The problem is how do u show the next or previous item on the listview when a button is clicked from another activity (detailed view activity).
I have entered image description here :
Attached are screen shots of the project with the next and previous buttons
Upvotes: 0
Views: 719
Reputation: 230
1 create your arraylist public static which is adapter use like this: public static ArrayList arraylist =new ArrayList<>(); in your class where you are set adapter
2.When you select any item you are getting position of the item from arraylist and store this value in store shared preference.
3.your arraylist from your MainActivity to SecondActivity. like this;
public static ArrayList arraylistSecond=MainActivity.arraylist;
when you click NEXT button get position the position from shared preference and increase position and get item.
and same when you click previous button decrease position and get item
happy coding
Upvotes: 0
Reputation:
You need to get the data from the array or arraylist whatever you are using for adapter. Adapter needs either array or list of data while creating. you can store this array or list for further access
Try with the following steps
Upvotes: 1