我创建了一个由自定义对象组成的arraylist.基本上用户将创建一个类,每次创建一个类时,都会在arraylist中添加一个新的Lecture(我的自定义对象).我需要保存生成的arraylist,以便即使重新启动应用程序也会保存用户的类.
根据我的理解,我必须使我的课程可序列化.但我究竟是怎么做到的呢?然后一旦它序列化我该怎么办?
public class Lecture{
public String title;
public String startTime;
public String endTime;
public String day;
public boolean classEnabled;
public Lecture(String title, String startTime, String endTime, String day, boolean enable){
this.title = title;
this.startTime = startTime;
this.endTime = endTime;
this.day = day;
this.classEnabled = enable;
}
//Getters and setters below
Run Code Online (Sandbox Code Playgroud) 我正在实现一个BaseAdapter,我有一个列表项的TranslateAnimation.
问题是当向下滚动时,其他视图具有相同的偏移量.
这是我的getView()方法实现:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView == null) {
//initialization code
convertView.setTag(viewHolder);
} else {
viewHolder =(ViewHolder) convertView.getTag();
}
Animation animation;
switch (item.getAnimationDirection()) {
case AnimationDirection.HIDE:
animation = new TranslateAnimation(itemOffset, 0, 0, 0);
animation.setDuration(200);
animation.setFillAfter(true);
viewHolder.layoutToAnimate.setAnimation(animation);
item.setAnimationDirection(AnimationDirection.HIDDEN);
break;
case AnimationDirection.REVEAL:
itemOffset = viewHolder.remove.getWidth() + 20;
animation = new TranslateAnimation(0, itemOffset, 0, 0);
animation.setDuration(200);
animation.setFillAfter(true);
viewHolder.layoutToAnimate.setAnimation(animation);
item.setAnimationDirection(AnimationDirection.SHOWING);
break;
}
viewHolder.remove.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View …Run Code Online (Sandbox Code Playgroud)