Asked
Active
Viewed 37 times
-4
-
2What is your question? Please read: https://stackoverflow.com/help/how-to-ask – zkoza May 15 '21 at 16:56
1 Answers
0
Assuming you want something like sliding images, if that is it I think you're looking for a ViewPager
You can add your content to the ViewPager. For them to automatically keep swiping you can try something like this or this.
This piece of code-block would achieve the same:
viewPager = (ViewPager) findViewById(R.id.viewPager);
PagerAdapter adapter = new CustomAdapter(MainActivity.this,imageId,imagesName);
viewPager.setAdapter(adapter);
/*After setting the adapter use the timer */
final Handler handler = new Handler();
final Runnable Update = new Runnable() {
public void run() {
if (currentPage == NUM_PAGES-1) {
currentPage = 0;
}
viewPager.setCurrentItem(currentPage++, true);
}
};
timer = new Timer(); // This will create a new Thread
timer.schedule(new TimerTask() { // task to be scheduled
@Override
public void run() {
handler.post(Update);
}
}, DELAY_MS, PERIOD_MS);
Hope that does what you need!

Yash Joshi
- 557
- 7
- 25