我正在使用ListViewAnimations我遇到了这个奇怪的问题, 如果列表包含多个元素,则跳过动画并填充所有视图,但如果只有一个元素要填充,则动画可以正常工作。
class AdapterOutcome extends CursorAdapter {
public AdapterOutcome(Context context, Cursor c, int flags) {
super(context, c, 0);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return LayoutInflater.from(context).inflate(R.layout.outcome_custom_row, parent, false);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
//finding the Views
TextView amonut = (TextView) view.findViewById(R.id.amount);
ImageView transactionType = (ImageView) view.findViewById(R.id.custom_row_icon);
TextView time = (TextView) view.findViewById(R.id.timeid);
TextView location = (TextView) view.findViewById(R.id.location);
TextView date = (TextView) view.findViewById(R.id.date);
TextView type_icon = (TextView) view.findViewById(R.id.type_icon);
//Creating Cursors for each View
String cursorTranscationType = cursor.getString(cursor.getColumnIndexOrThrow("_transactionType"));
String cursorAmount = cursor.getString(cursor.getColumnIndexOrThrow("_amount"));
String cursorTime = cursor.getString(cursor.getColumnIndexOrThrow("_time"));
String cursorLocation = cursor.getString(cursor.getColumnIndexOrThrow("_location"));
String cursorDay = cursor.getString(cursor.getColumnIndexOrThrow("_day"));
String cursorMonth = cursor.getString(cursor.getColumnIndexOrThrow("_month"));
String cursorYear = cursor.getString(cursor.getColumnIndexOrThrow("_year"));
DateFormat dateformat = DateFormat.getDateInstance(DateFormat.MEDIUM);
// Date myDate = new Date(Integer.parseInt(cursorYear)-1900, Integer.parseInt(cursorMonth)-1, Integer.parseInt(cursorDay));
//set the data from the Cursor to the Views
amonut.setText(String.valueOf("- " + cursorAmount));
time.setText(String.valueOf(cursorTime));
location.setText(String.valueOf(cursorLocation));
// date.setText( dateformat.format(myDate));
if (cursorTranscationType.equals("Purchase")) {
type_icon.setText("P");
}
else{
type_icon.setText("C");
}
}
}
答案 0 :(得分:0)
您是否为列表视图使用自定义适配器?如果是,则将getView的最后一个位置保存在全局int变量中,当下一个需要填充视图时,使用最后一个位置。 如果这还不够清楚,请发布您的代码示例。