Banner-Slider
Banner-Slider copied to clipboard
problem in collapsing toolbarlayout
when use this slider inside CollapsingToolbarLayout this error run:
Host activity must extend AppCompatActivity
java.lang.RuntimeException: **# Host activity must extend AppCompatActivity** at ss.com.bannerslider.views.BannerSlider$1.run(BannerSlider.java:117) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Your activity that banner slider is on it, must extend AppCompatActivity
I have extended activity with AppCompatActivity still problem is not resolved
Can you please upload the full code? I am working on a Design like that
این مشکل منم هست . میشه راهنمایی کنین که چطور میتونم حلش کنم ؟
This library is Fragment based and it needed the Activity to use this. The problem is if you use the slider view into CollapsingToolbarLayout, so the result from the getContext() this library is ContextThemeWrapper instead AppCompatActivity.
You can solve the problem by obtaining the parent AppCompatActivity from that ContextThemeWrapper.
Open ss/com/bannerslider/views/BannerSlider.java file on line 121. And change it from:
if (getContext() instanceof AppCompatActivity) {
hostActivity = (AppCompatActivity) getContext();
} else {
throw new RuntimeException("Host activity must extend AppCompatActivity");
}
to
if (getContext() instanceof AppCompatActivity) {
hostActivity = (AppCompatActivity) getContext();
} else if(getContext() instanceof android.view.ContextThemeWrapper){
hostActivity = (AppCompatActivity) ((ContextWrapper) getContext()).getBaseContext(); // this is to get the AppCompatActivity from the ContextThemeWrapper
} else {
throw new RuntimeException("Host activity must extend AppCompatActivity");
}
After that you can use the slider into CollapsingToolbarLayout view.
@andisusilo tnx for your answer but could u tell me how change a jar file without open it ?
or how make it writable in android studio because files are read only .
@ali-amani add this library as source, merge with your source code (download and merge with your source code). Don't adding in gradle.
I have the same problem there is no better solution.
when I using toolbar layout, interval was not working any solution ?