【问题标题】:Android: Many Edittexts in ListViewAndroid:ListView 中有许多 Edittexts
【发布时间】:2011-04-12 06:18:36
【问题描述】:

这是我的 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;
    }
}

但这不起作用。 编辑文本不显示正确的文本,显示的文本在滚动时切换。 下一个问题是,我在清单中设置了 android:windowSoftInputMode="adjustPan" 。 如果您单击进入最后一个编辑文本,列表视图将无法向上滚动到足以让您看到您正在输入的内容。

【问题讨论】:

    标签: android listview android-edittext


    【解决方案1】:

    很抱歉没有直接回答您的问题,但如果我是您,我会重新设计该列表。 用户使用列表中的编辑字段将成为主要的 PITA。我会做什么 - 要么使用长按动作并带来对话框或对话框活动进行编辑,要么使用快速动作模式

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-20
      相关资源
      最近更新 更多