所以我的问题是这个。我有一个listview,每行都有一个viewflipper。当数据变得更多并且它们不适合屏幕时,当我点击一行来启用viewflipper时,它会翻转该行,但它也会翻转屏幕下方的另一行。(如果我向下滚动,我可以看到它)< / p>
有时如果我再次向上和向下滚动,翻转的行(第二行)会切换回正常并再次翻转。
这是我的适配器
public class HistoryBaseAdapter extends BaseAdapter {
private static ArrayList<HistoryResults> searchArrayList;
private Context CONTEXT;
public HistoryBaseAdapter(Context context, ArrayList<HistoryResults> results, boolean length) {
searchArrayList = results;
mInflater = LayoutInflater.from(context);
log_length = length;
CONTEXT = context;
}
@Override
public int getCount() {
return searchArrayList.size();
}
@Override
public Object getItem(int position) {
return searchArrayList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.history_row_view, null);
holder = new ViewHolder();
holder.flipper = (ViewFlipper) convertView.findViewById(R.id.flipper);
holder.flipper.setInAnimation(AnimationUtils.loadAnimation(CONTEXT, R.anim.slide_in));
holder.flipper.setOutAnimation(AnimationUtils.loadAnimation(CONTEXT, R.anim.slide_out));
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.flipper.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
holder.flipper.showNext();
}
});
return convertView;
}
static class ViewHolder {
ViewFlipper flipper;
}
}
有谁知道出了什么问题?
答案 0 :(得分:1)
实际上@Raghunandan帮了!! https://www.youtube.com/watch?v=8MIfSxgsHIs
我刚添加了2行
holder.flipper.setOnClickListener(new OnClickListener() {
boolean hasTransientState = true;
@Override
public void onClick(View v) {
holder.flipper.showNext();
holder.flipper.setHasTransientState(hasTransientState);
hasTransientState = !hasTransientState;
}
});
我不确定它是否是更有效的方法,但它有效! 谢谢!