我與Fade In Animation
在ListView
列表視圖行淡入動畫
工作,但我面對的奇怪的錯誤動畫多次:
一些行再次動畫但是getView()不是召之即來。 。 這怎麼可能 ?
我的自定義適配器如下:MyAdapter.java
public class MyAdapter extends ArrayAdapter<String> {
private Context mContext;
private Animation mAnim;
private String[] mData;
private ListView mList;
public MyAdapter(Context context, int resource, String[] objects, ListView mList) {
super(context, resource, objects);
this.mContext = context;
mAnim = AnimationUtils.loadAnimation(context, R.anim.fade_in);
this.mData = objects;
this.mList = mList;
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(android.R.layout.simple_list_item_1, parent, false);
ViewHolder mHolder;
if (convertView == null) {
mHolder = new ViewHolder();
} else {
mHolder = (ViewHolder) convertView.getTag();
}
view.setTag(mHolder);
mHolder.mTextview = (TextView) view.findViewById(android.R.id.text1);
mHolder.mTextview.setText(mData[position]);
if (mList.getFirstVisiblePosition() < position && position <= (mList.getFirstVisiblePosition() + mList.getChildCount())) {
Log.w("list", "scroll down..");
view.startAnimation(mAnim);
} else if (position < mList.getFirstVisiblePosition()) {
Log.w("list", "scroll up..");
view.startAnimation(mAnim);
}
return view;
}
static class ViewHolder {
private TextView mTextview;
}
}
任何幫助是極大的appriciated ..
謝謝
這是工作..謝謝你的幫助.. – Kushal