我正在使用以下代码在列表视图中显示编辑框
我的每个 ListView 项目都包含以下模式
[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,但是一旦键盘消失,文本就几乎消失了。编辑文本显示空白。
怎么了?