简体   繁体   English

Android:ListView中有许多Edittext

[英]Android: Many Edittexts in ListView

this is my getView method: 这是我的getView方法:

    public View getView(final int position, View convertView, final ViewGroup parent) {
        ViewHolder holder;
        if(convertView == null){
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.propviewlistrow, null);
            holder.title = (TextView) convertView.findViewById(R.id.propviewlistrow_t1);
            holder.content = (EditText) convertView.findViewById(R.id.propviewlistrow_e1);
            convertView.setTag(holder);
        }
        else{
            holder = (ViewHolder)convertView.getTag();
        }
        holder.title.setText(names.get(position));
        holder.content.setText(values.get(position));       
        holder.content.addTextChangedListener(new TextWatcher(){

            public void afterTextChanged(Editable s) {      
                values.set(position, s.toString());
            }

            public void beforeTextChanged(CharSequence s, int start,
                    int count, int after) {
            }

            public void onTextChanged(CharSequence s, int start,
                    int before, int count) {
                    }

        });
        return convertView;
    }
}

But this does not work. 但这是行不通的。 The edittexts do not display the proper text, the displayed text switches while scrolling. 编辑文本不会显示正确的文本,滚动时显示的文本会切换。 The next issue is, I have set android:windowSoftInputMode="adjustPan" in the manifest. 下一个问题是,我在清单中设置了android:windowSoftInputMode =“ adjustPan”。 If you click the into the last edittext, the listview won't scroll up enough so that you can see what you are typing. 如果在最后一个编辑文本中单击,则列表视图将不会向上滚动,因此您无法看到正在键入的内容。

Sorry for not answering your question directly, but if i were you i'd redesign that list. 很抱歉没有直接回答您的问题,但是如果我是您,我会重新设计该列表。 It's gonna be major PITA for the user to use edit fields in the list. 用户使用列表中的编辑字段将成为主要的PITA。 What i'd do - either use long-press action and bring dialog or dialog activity to edit, or use quick actions pattern 我要做什么-使用长按动作并启用对话框或对话框活动进行编辑,或使用快速动作模式

http://android-developers.blogspot.com/2010/05/twitter-for-android-closer-look-at.html http://android-developers.blogspot.com/2010/05/twitter-for-android-closer-look-at.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM