當我滾動它時,我的listview重新排序。這很混亂。爲什麼當我滾動瀏覽時,我的listview重新排序?
下面是我使用的自定義適配器:
public class LoadExpenseList extends BaseAdapter{
List<Expense> expenses;
Context context;
public LoadExpenseList(Context context, int textViewResourceId,
List<Expense> expenses) {
super();
this.expenses = expenses;
this.context = context;
}
public View getView(final int position, View convertView, ViewGroup parent){
//View v = convertView;
AvailableExpenseView btv;
if (convertView == null) {
btv = new AvailableExpenseView(context, expenses.get(position));
} else {
btv = (AvailableExpenseView) convertView;
}
btv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.i("Expense_Availables", "Item Selected!!");
Intent intent = new Intent(getActivity(), ItemDetailActivity.class);
int id = expenses.get(position).getExpenseItemId();
intent.putExtra("id", id);
startActivity(intent);
}
});
btv.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View arg0) {
// TODO Auto-generated method stub
return false;
}
});
registerForContextMenu(btv);
return btv;
}
@Override
public int getCount() {
return expenses.size();
}
@Override
public Object getItem(int position) {
return expenses.get(position);
}
@Override
public long getItemId(int position) {
return expenses.get(position).getExpenseItemId();
}
}
你能解釋一下你的意思嗎?我不太清楚你的意思。 – Cody 2012-01-04 18:00:23
當然不適合編輯我的答案。 – aromero 2012-01-04 18:06:00