xml を使用して編集テキスト フィールドを作成し、列挙子を使用して listview のアダプタ クラス .im に追加します。これにより、同じ ID を持つ 2 つのテキスト フィールドを作成できました。問題は、両方のテキスト フィールドから文字列を取得する方法です。それらは同じ 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;
}