我正在使用 xml 创建一个编辑文本文件,并使用 enumerator 在 listview 的适配器类 .im 中添加它。通过这个我能够创建两个具有相同 id 的文本字段。问题是如何从两个文本字段中获取字符串因为他们共享相同的 id。下面是代码。
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View rowView = null;
AddKeywordRow row = keywordRows.get(position);
switch (row.getRowType()) {
case TitleRow:
rowView = inflater.inflate(R.layout.titlerow, null);
TextView txtTitle = (TextView) rowView.findViewById(R.id.rowtitle);
txtTitle.setText(row.getMessage());
break;
case EditRow:
rowView = inflater.inflate(R.layout.editrow, null);
txtInput = (EditText) rowView.findViewById(R.id.rowedit);
txtInput.setHint(row.getMessage());
if (row.getHeight() != 0)
{
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,row.getHeight());
txtInput.setLayoutParams(layoutParams);
layoutParams.setMargins(7, 0, 7,0);
//txtInput.setLayoutParams(new LinearLayout.LayoutParams(
// LinearLayout.LayoutParams.MATCH_PARENT, row.getHeight()));
txtInput.setPadding(3,0,0,30);
}
// set padding and margin
break;
case MessageRow:
rowView = inflater.inflate(R.layout.messagerow, null);
TextView txtMessage = (TextView) rowView
.findViewById(R.id.rowmessage);
txtMessage.setText(row.getMessage());
break;
case ButtonRow:
rowView = inflater.inflate(R.layout.buttonrow, null);
Button btn = (Button)rowView.findViewById(R.id.button1);
btn.setOnClickListener(new OnClickListener() {
}
});
break;
}
return rowView;
}