扩展Viewpage 类,结果得到java.lang.RuntimeException
。
Unable to start activity ComponentInfo{com.pindak.sarito/com.pindak.sarito.ui.ws.MagazineReaderActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class com.pindak.sarito.util.HackyViewPager
布局文件:
<?xml version="1.0" encoding="utf-8"?>
<com.pindak.sarito.util.HackyViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/magazinepager"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
onCreate的部分代码:
HackyViewPager pager = (HackyViewPager) findViewById(R.id.magazinepager);
在com.pindak.sarito.util中的HackyViewPager.java
package com.pindak.sarito.util;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.view.MotionEvent;
public class HackyViewPager extends ViewPager {
public HackyViewPager(Context context) {
super(context);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
try {
return super.onInterceptTouchEvent(ev);
} catch (IllegalArgumentException e) {
e.printStackTrace();
return false;
}
}
}
不知道为什么会出现这个错误?