相同的ID我创建使用XML和添加编辑文本提交,在列表视图中的适配器类.IM使用enumerator.by这我能创建两个文本框与同样id.the问题是如何从文本字段得到的字符串,因为它们共享相同的id.below是代码。如何从多个编辑文本的文本与机器人
@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;
}
有没有简单的方法来做到这一点,我认为。你必须通过你的listview中的每一个孩子,并检查它是否有这个ID,如果这是你想要的方法。也许可以考虑使用别的东西,然后列表视图这..这并不意味着使用这种方式。但是,就是要用来创建相同的项目列表..喜欢用表格数据的表。使用上述code..would –