如何在Android中动态生成EditText数据?

问题描述 投票:0回答:1

我能够动态生成多个editText,但不了解如何使用intent将其文本用于Next活动

public void onAddField(View v) {
        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        final View rowView = inflater.inflate(R.layout.field, null);
        parentLinearLayout.addView(rowView, parentLinearLayout.getChildCount() - 1);

    }
public void onDelete(View v) {
        parentLinearLayout.removeView((View) v.getParent());
    }
java android android-intent android-edittext
1个回答
2
投票

将所有editexts添加到列表中..

List<EditText> edt_all = new ArrayList<EditText>();

然后你会得到数据

for(int i=0; i < edt_all.size(); i++){
    string[i] = edt_all.get(i).getText().toString();
    Log.e("##edittext ", string[i])
} 
© www.soinside.com 2019 - 2024. All rights reserved.