android listview order changed when called notifyDataSetChanged

Posted by 9nix00 on Stack Overflow See other posts from Stack Overflow or by 9nix00
Published on 2011-02-19T07:58:24Z Indexed on 2011/02/26 7:25 UTC
Read the original article Hit count: 187

Filed under:
|

hi,all. when I use notifyDataSetChanged(), the listview display order will be change .

like this

  • 3
  • 2
  • 1

    when current activy was created. but when I change the data. it will be

  • 1
  • 2
  • 3

I don't want the order changed and i dont understand why its happening.

This is a piece of code from my adapter class

    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();
        }



}

I change data at some dialog like this

       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();
}})

© Stack Overflow or respective owner

Related posts about android

Related posts about listview