アダプターでStickyGridHeadersを使用しています。グリッドからアイテムを使用しようとするまで、すべて正常に動作しますAnimation
(削除されたときにアイテムをフェードアウトしたい)。
getView のこの部分は機能します。
public View getView(int position, View convertView, final ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = myInflater.inflate(R.layout.item_savedsearchlist,
null);
holder = new ViewHolder();
holder.Tv1 = (TextView) convertView.findViewById(R.id.textView1);
convertView.setTag(holder);
}
else {
holder = (ViewHolder) convertView.getTag();
}
holder.Deletebtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Animation anim = AnimationUtils.loadAnimation(ctx,
android.R.anim.slide_out_right);
anim.setAnimationListener(new Animation.AnimationListener() {
removeThisItem();
notifiyDataSetChanged;
}
});
return convertView;
}
これはしません:
public View getView(int position, View convertView, final ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = myInflater.inflate(R.layout.item_savedsearchlist,
null);
holder = new ViewHolder();
holder.Tv1 = (TextView) convertView.findViewById(R.id.textView1);
convertView.setTag(holder);
}
else {
holder = (ViewHolder) convertView.getTag();
}
final View rc = holder.Tv1; // I tried this with different Views from the item layout
holder.Deletebtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Animation anim = AnimationUtils.loadAnimation(ctx,
android.R.anim.slide_out_right);
anim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
removeThisItem();
notifyDataSetChanged();
}
});
rc.startAnimation(anim);
}
});
return convertView;
}
2 番目のバージョンでは、次のエラーが発生します。
06-13 11:01:59.957: E/AndroidRuntime(1045): FATAL EXCEPTION: main
06-13 11:01:59.957: E/AndroidRuntime(1045): java.lang.NullPointerException
06-13 11:01:59.957: E/AndroidRuntime(1045): at com.tonicartos.widget.stickygridheaders.StickyGridHeadersGridView.dispatchDraw(StickyGridHeadersGridView.java:774)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.View.draw(View.java:11180)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.widget.AbsListView.draw(AbsListView.java:3769)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.ViewGroup.drawChild(ViewGroup.java:2895)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.ViewGroup.drawChild(ViewGroup.java:2893)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.ViewGroup.drawChild(ViewGroup.java:2893)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.ViewGroup.drawChild(ViewGroup.java:2893)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.View.draw(View.java:11180)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.support.v4.view.ViewPager.draw(ViewPager.java:1574)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.ViewGroup.drawChild(ViewGroup.java:2895)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.View.draw(View.java:11180)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.widget.FrameLayout.draw(FrameLayout.java:450)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.ViewGroup.drawChild(ViewGroup.java:2895)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.ViewGroup.drawChild(ViewGroup.java:2893)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.View.draw(View.java:11180)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.widget.FrameLayout.draw(FrameLayout.java:450)
06-13 11:01:59.957: E/AndroidRuntime(1045): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2295)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2231)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1837)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2649)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.os.Handler.dispatchMessage(Handler.java:99)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.os.Looper.loop(Looper.java:137)
06-13 11:01:59.957: E/AndroidRuntime(1045): at android.app.ActivityThread.main(ActivityThread.java:4507)
06-13 11:01:59.957: E/AndroidRuntime(1045): at java.lang.reflect.Method.invokeNative(Native Method)
06-13 11:01:59.957: E/AndroidRuntime(1045): at java.lang.reflect.Method.invoke(Method.java:511)
06-13 11:01:59.957: E/AndroidRuntime(1045): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:978)
06-13 11:01:59.957: E/AndroidRuntime(1045): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
06-13 11:01:59.957: E/AndroidRuntime(1045): at dalvik.system.NativeStart.main(Native Method)
アイテムの膨張したレイアウトが GridHeader と何の関係があるのか 本当にわかりません。アイデアはありますか?:)