Skip to content Skip to sidebar Skip to footer

Android Next Item On Listview From Second Activity

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

Solution 1:

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;

  1. when you click NEXT button get position the position from shared preference and increase position and get item.

  2. and same when you click previous button decrease position and get item

happy coding

Post a Comment for "Android Next Item On Listview From Second Activity"