Stack Overflow Asked by Loopinfility on August 28, 2020
So i am trying to run an android application on my device, however i am getting the same run time error every time java.lang.ArithmeticException: divide by zero so my application starts and closes immediately.
In the log says that is Caused by: java.lang.ArithmeticException: divide by zero. Accordingly i am going to present you what the code is in those three lines.
1.**at com.daimajia.slider.library.SliderLayout.setCurrentPosition(SliderLayout.java:664)
2. at com.daimajia.slider.library.SliderLayout.setCurrentPosition(SliderLayout.java:670)
3.at com.example.testapp.MainActivity.onCreate(MainActivity.java:53)**
2.
public void setCurrentPosition(int position) {
**setCurrentPosition(position, true);**
}
3.
mainSlider = (SliderLayout) findViewById(R.id.main_slider);
setSlider();
PagerIndicator pagerIndicator = (PagerIndicator) findViewById(R.id.custom_indicator);
mainSlider.setCustomIndicator(pagerIndicator);
mainSlider.setDuration(3);
**mainSlider.setCurrentPosition(app.heritageSites.size() - 1);**
The lines which have the asterisks are those one’s who have the problem.
Try handling the exception:
try {
mainSlider.setCurrentPosition(app.heritageSites.size() - 1);
} catch (ArithmeticException e) {
e.printStackTrace();
}
Answered by afhamu on August 28, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP