问题描述
- ListView 中 Edit Text 的错误
-
我使用下面的代码在 list view 中显示edit boxes
现在每一个 ListView item 包含以下模式:[EditText 1] [EditText 2] [EditText 3 ][EditText 4][EditText 5] class CustomArrayAdapterForScore extends ArrayAdapter<ScoreModel> { public CustomArrayAdapterForScore() { super(MeetScore.this, R.layout.score_event_layout, myScoreArray); } @Override public View getView(final int position, View convertView, ViewGroup parent) { View view = null; LayoutInflater inflator = MeetScore.this.getLayoutInflater(); view = inflator.inflate(R.layout.score_event_layout, parent, false); final ViewHolder viewHolder = new ViewHolder(); viewHolder.title = (TextView) view.findViewById(R.id.title); viewHolder.box1 = (EditText) view.findViewById(R.id.box1); viewHolder.box2 = (EditText) view.findViewById(R.id.box2); viewHolder.box3 = (EditText) view.findViewById(R.id.box3); viewHolder.box4 = (EditText) view.findViewById(R.id.box4); viewHolder.box5 = (EditText) view.findViewById(R.id.box5); viewHolder.box6 = (EditText) view.findViewById(R.id.box6); viewHolder.box1.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence c, int arg1, int arg2, int arg3) { ScoreModel score = myScoreArray.get(position); score.box1 = Integer.valueOf(viewHolder.box1.getText().toString()); myScoreArray.set(position, score); listView.invalidateViews(); } public void beforeTextChanged(CharSequence c, int arg1, int arg2, int arg3){} public void afterTextChanged(Editable arg0){} }); view.tag(viewHolder); return view;
当我改变Editbox 的文本时,点击它然后使用键盘输入。例如我输入9它显示9。 但是当键盘消失后,text
也不显示了。 edit text 显示空白区。
这是什么错误啊?
时间: 2024-10-06 11:29:33