EditText in a list aren't working the way they should

前端 未结 3 1331
猫巷女王i
猫巷女王i 2021-01-27 16:01

I have a problem with EditText fields in a ListActivity.

The code complies all right, but the functionality is strange, typing in the first fie

3条回答
  •  执念已碎
    2021-01-27 16:51

    This will help you

    ``

    private class EfficientAdapter extends BaseAdapter {
                private LayoutInflater mInflater;
                private String[] attitude_names;
                public String[] attitude_values;
                private String name;
        public static HashMap myList=new HashMap();
    
                public EfficientAdapter(Context context) {
                    mInflater = LayoutInflater.from(context);
                    attitude_names = context.getResources().getStringArray(R.array.COMP_ATTITUDE_NAME);
                    attitude_values = new String[attitude_names.length];
                }
        // initialize myList
        for(int i=0;i

    Here I have included a HashMap object which will keep on eye of what EditText contains value.And when you scroll the listview,it will be rendered again by calling its getView method.

    In this code,when you firstly load listview,all your edittext will be with no text.once you enter some text,it will be noted in myList.So when you again render the list,your text would be prevented.

提交回复
热议问题