我正在使用converflow布局 按照给定库https://github.com/moondroid/CoverFlow中的说明进行操作 它按照我的方式推出时完全没问题, 但问题是当我点击屏幕时,应用程序崩溃在棒棒糖设备中观察到
< ---- mainactivity ---->
CoverFlowAdapter adapter = new CoverFlowAdapter(this);
FeatureCoverFlow featureCoverFlow = (FeatureCoverFlow) findViewById(R.id.coverflow);
featureCoverFlow.setAdapter(adapter);
< - xml used - >
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:coverflow="http://schemas.android.com/apk/res-auto">
<it.moondroid.coverflow.components.ui.containers.FeatureCoverFlow
android:id="@+id/coverflow"
android:layout_width="match_parent"
android:layout_height="match_parent"
coverflow:coverHeight="150dp"
coverflow:coverWidth="150dp"
coverflow:maxScaleFactor="1.5"
coverflow:reflectionGap="0px"
coverflow:rotationThreshold="0.5"
coverflow:scalingThreshold="0.5"
coverflow:spacing="0.6" />
</LinearLayout>
&lt; - CoverFlowAdapter - &gt;
public class CoverFlowAdapter extends BaseAdapter {
private final ArrayList<String> mListString;
private LayoutInflater mLayoutInflator;
public CoverFlowAdapter(MainActivity activity) {
mLayoutInflator = LayoutInflater.from(activity);
mListString = new ArrayList<>();
mListString.add("one");
mListString.add("two");
mListString.add("three");
mListString.add("four");
mListString.add("five");
}
@Override
public int getCount() {
return mListString.size();
}
@Override
public String getItem(int position) {
return mListString.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = convertView;
if (rowView == null) {
rowView = mLayoutInflator.inflate(R.layout.cover_flow_item,
parent, false);
ViewHolder viewHolder = new ViewHolder();
viewHolder.text = (TextView) rowView.findViewById(R.id.label);
rowView.setTag(viewHolder);
}
ViewHolder holder = (ViewHolder) rowView.getTag();
holder.text.setText(mListString.get(position));
return rowView ;
}
static class ViewHolder {
public TextView text;
}
}
&lt; ---将错误视为 - &gt;
java.lang.NullPointerException:尝试从字段中读取&#39; int android.view.View.mViewFlags&#39;在null对象引用上 在android.view.ViewGroup.canViewReceivePointerEvents(ViewGroup.java:2316) 在android.view.ViewGroup.dispatchHoverEvent(ViewGroup.java:1581) 在android.view.View.dispatchGenericMotionEvent(View.java:8552) 在android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:1919) 在android.view.ViewGroup.dispatchHoverEvent(ViewGroup.java:1624) 在android.view.View.dispatchGenericMotionEvent(View.java:8552) 在android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:1919) 在android.view.ViewGroup.dispatchHoverEvent(ViewGroup.java:1624) 在android.view.View.dispatchGenericMotionEvent(View.java:8552) 在android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:1919) 在android.view.ViewGroup.dispatchHoverEvent(ViewGroup.java:1624) 在android.view.View.dispatchGenericMotionEvent(View.java:8552) 在android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:1919) 在android.view.ViewGroup.dispatchHoverEvent(ViewGroup.java:1624) 在android.view.View.dispatchGenericMotionEvent(View.java:8552) 在android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:1919) 在android.view.ViewGroup.dispatchHoverEvent(ViewGroup.java:1624) 在android.view.View.dispatchGenericMotionEvent(View.java:8552) 在android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:1919) 在android.view.ViewGroup.dispatchHoverEvent(ViewGroup.java:1624) 在android.view.View.dispatchGenericMotionEvent(View.java:8552) 在com.android.internal.policy.impl.PhoneWindow $ DecorView.superDispatchGenericMotionEvent(PhoneWindow.java:2377) 在com.android.internal.policy.impl.PhoneWindow.superDispatchGenericMotionEvent(PhoneWindow.java:1729) 在android.app.Activity.dispatchGenericMotionEvent(Activity.java:2778) 在android.support.v7.view.WindowCallbackWrapper.dispatchGenericMotionEvent(WindowCallbackWrapper.java:70) 在com.android.internal.policy.impl.PhoneWindow $ DecorView.dispatchGenericMotionEvent(PhoneWindow.java:2344) 在android.view.View.dispatchPointerEvent(View.java:8668) 在android.view.ViewRootImpl $ ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4123) 在android.view.ViewRootImpl $ ViewPostImeInputStage.onProcess(ViewRootImpl.java:3989) 在android.view.ViewRootImpl $ InputStage.deliver(ViewRootImpl.java:3544) 在android.view.ViewRootImpl $ InputStage.onDeliverToNext(ViewRootImpl.java:3597) 在android.view.ViewRootImpl $ InputStage.forward(ViewRootImpl.java:3563) 在android.view.ViewRootImpl $ AsyncInputStage.forward(ViewRootImpl.java:3680) 在android.view.ViewRootImpl $ InputStage.apply(ViewRootImpl.java:3571) 在android.view.ViewRootImpl $ AsyncInputStage.apply(ViewRootImpl.java:3737) 在android.view.ViewRootImpl $ InputStage.deliver(ViewRootImpl.java:3544) 在android.view.ViewRootImpl $ InputStage.onDeliverToNext(ViewRootImpl.java:3597) 在android.view.ViewRootImpl $ InputStage.forward(ViewRootImpl.java:3563) 在android.view.ViewRootImpl $ InputStage.apply(ViewRootImpl.java:3571) 在android.view.ViewRootImpl $ InputStage.deliver(ViewRootImpl.java:3544) 在android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5807) 在android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5781) 在android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5752) 在android.view.ViewRootImpl $ WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5897) 在android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185) 在android.os.MessageQueue.nativePollOnce(本机方法) 在android.os.MessageQueue.next(MessageQueue.java:143) 在android.os.Looper.loop(Looper.java:122) 在android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) 在java.lang.reflect.Method.invoke(Method.java:372) 在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:903) 在com.android.internal.os.ZygoteInit.m