Hello,
I am facing the problem of class not found exception in my project when i used your code. And I am using your code with actionbar sherlock
You are passing color array and I am passing image array. and I have already added your InfiniteViewPager.java and InfinitePagerAdapter as it is .
Here is ,my code and log cat.
Log Cat :-
12-26 10:24:58.648 1157-1157/com.bito1.Shoplu E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bito1.Shoplu/com.bito1.Shoplu.Main.actMain}: android.view.InflateException: Binary XML file line #8: Error inflating class com.antonyt.infiniteviewpager.InfiniteViewPager
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.antonyt.infiniteviewpager.InfiniteViewPager
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(ActionBarSherlockNative.java:133)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:261)
at com.bito1.Shoplu.Main.actMain.onCreate(actMain.java:26)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.antonyt.infiniteviewpager.InfiniteViewPager" on path: DexPathList[[zip file "/data/app/com.bito1.Shoplu-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.bito1.Shoplu-1, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.view.LayoutInflater.createView(LayoutInflater.java:559)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(ActionBarSherlockNative.java:133)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:261)
at com.bito1.Shoplu.Main.actMain.onCreate(actMain.java:26)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
I am attching my Main Activity and main.xml and my fragment class file. so please check out and let me know the solution.
MainActivity:-
public class actMain extends SherlockFragmentActivity implements View.OnClickListener {
Button BTN_FACEBOOK;
ViewPager PAGER;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initiatePageControls();
startTour();
}
private void startTour() {
PagerAdapter _adapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
int[] _images = new int[]{R.drawable.ic_launcher, R.drawable.a, R.drawable.b, R.drawable.c, R.drawable.d};
@Override
public int getCount() {
return _images.length;
}
@Override
public Fragment getItem(int position) {
Fragment _fragment = new frg_tour_slide();
Bundle _args = new Bundle();
_args.putInt("images", _images[position]);
_args.putInt("position", position);
_fragment.setArguments(_args);
return _fragment;
}
};
PagerAdapter _wrappedAdapter = new InfinitePagerAdapter(_adapter);
PAGER.setAdapter(_wrappedAdapter);
}
private void initiatePageControls() {
BTN_FACEBOOK = (Button) findViewById(R.id.btnFacebook);
BTN_FACEBOOK.setOnClickListener(this);
PAGER = (ViewPager) findViewById(R.id.pager);
}
@Override
public void onClick(View view) {
if (view.getId() == BTN_FACEBOOK.getId()) {
startActivity(new Intent(getApplicationContext(), actTestService.class));
//startActivity(new Intent(getApplicationContext(), actFacebook.class));
}
}
}
Fragment :-
public class frg_tour_slide extends SherlockFragment {
ImageView SLIDE_1;
private int IMAGES;
private int IMAGE_POSITION;
private Context CONTEXT;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle args = getArguments();
IMAGES = args.getInt("images");
IMAGE_POSITION = args.getInt("position");
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View _view = inflater.inflate(R.layout.tour_slide, null);
SLIDE_1 = (ImageView) _view.findViewById(R.id.imgSlideShow);
SLIDE_1.setImageResource(IMAGES);
return _view;
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean("dummy", true);
}
}
Please help me for this issue.
Thanking you in advance.