EditText文本滚动时消失

时间:2014-03-01 13:01:12

标签: android scroll android-edittext android-tablelayout android-scrollview

我有一个滚动视图,表格布局为14行,每行有2个EditText字段。我有用户点击的按钮,程序计算并打印答案。问题是,一旦用户单击该按钮,然后在EditText中进行更改并再次单击该按钮,然后向上滚动在更改的EditText字段中输入的字符消失,但是当用户单击它时,它会重新启用。请帮我解决这个问题。这是xml文件。

详细问题: -
1.用户在EditText字段中输入文本 2.用户单击按钮 3.用户在一个或多个EditText字段中进行更改 4.用户单击按钮 5.在最后更改的EditText字段中输入的字符消失。

链接到完整的XML代码: - http://pastebin.com/G01TcXN1

链接到完整的JAVA代码: - http://pastebin.com/utRMQ60B

请帮我解决这个问题。

2 个答案:

答案 0 :(得分:1)

我解决了它我刚刚从 RelativeLayout 更改为 LinearLayout 那解决了我的问题。

答案 1 :(得分:0)

您可以按照以下代码对它有所帮助。

if (convertView == null) {

        holder = new ViewHolder();

        LayoutInflater vi = (LayoutInflater)    
        getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = vi.inflate(R.layout.element_in_game, null);

        holder.scoreToUpdate = (EditText) convertView
                .findViewById(R.id.elementUpdateScore);

        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();

    }
   initScoresToUpdateEditTexts(holder.scoreToUpdate, hint);
   holder.scoreToUpdate.setText(scoresToUpdate[tmp_position]);
   holder.scoreToUpdate.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start,
                    int before, int count) {
                scoresToUpdate[tmp_position] = s.toString();
            }
        });

    return convertView;
}

或者您也可以参考此LINK