【发布时间】:2011-06-30 07:03:54
【问题描述】:
全部。 当我使用 notifyDataSetChanged() 时,listview 的显示顺序会发生变化。
喜欢这个
- 3
- 2
-
1
当前活动的创建时间。但是当我更改数据时。会是
- 1
- 2
- 3
我不想改变订单,我不明白为什么会这样。
这是我的适配器类中的一段代码
public static class ItemAdapter extends BaseAdapter {
private String[] mData;
private LayoutInflater mInflater;
// I called this method to change data
public void setEditText(int position, final String item) {
mData[position] = item;
notifyDataSetChanged();
}
}
我在这样的对话框中更改数据
builder = new AlertDialog.Builder(ct);
builder.setTitle(R.string.pickStatus)
.setView(edBuffer)
.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialog, int id) {
// TODO Auto-generated method stub
canPop = true;
final String tmp = edBuffer.getText().toString();
KbonezLog.e(String.format( "set into key %d", key));
//use mData key to set value
setEditText(key, tmp);
dialog.dismiss();
}})
【问题讨论】:
-
目前看起来还不错。让我们看看您对 Adapter.getView() 的实现。
-
发布一段从适配器创建适配器和 getView() 方法的 sn-p 代码。您还可以添加一个 sn-p 如何获取“关键”变量。
标签: android listview baseadapter